#include #include template class Matrix { public: int m,n; std::vector values; Matrix(int _m, int _n) : m(_m), n(_n), values(n*m) {} typename std::vector::reference operator()(int i, int j) { return values[i*n+j];} class Row { public: Matrix &mat; int row; Row(Matrix &_mat,int _row) : mat(_mat), row(_row) {} typename std::vector::reference operator()(int j) { return mat.values[row*mat.n+j];} }; class Column { public: Matrix &mat; int col; Column(Matrix &_mat,int _col) : mat(_mat), col(_col) {} typename std::vector::reference operator[](int i) { return mat.values[i*mat.n+col];} }; Row operator[](int i) { return Row(*this,i); } Column operator()(int j) { return Column(*this,j); } }; main() { const int COUNT=1000000; const int SIZE=100; Matrix A(SIZE,SIZE); for(int i=0;i