#include <iostream>
#include <vector>
class My_vec {
enum { ROWS = 0, COLS = 1};
std::vector<int> v;
int sz[2];
public:
My_vec(int rows, int cols)
:v(rows*cols)
{
sz[ROWS] = rows;
sz[COLS] = cols;
}
inline int* operator[](int n) {
return &v[n*sz[ROWS]];
}
};
int main() {
My_vec v {2, 2};
for (auto i = 0; i < 2; ++i)
for (auto j = 0; j < 2; ++j)
v[i][j] = i * 2 + j;
for (auto i = 0; i < 2; ++i) {
for (auto j = 0; j < 2; ++j)
std::cout << v[i][j] << ' ';
std::cout << '\n';
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKY2xhc3MgTXlfdmVjIHsKCWVudW0geyBST1dTID0gMCwgQ09MUyA9IDF9OwoJc3RkOjp2ZWN0b3I8aW50PiB2OwoJaW50IHN6WzJdOwoJCnB1YmxpYzoKCU15X3ZlYyhpbnQgcm93cywgaW50IGNvbHMpCgk6dihyb3dzKmNvbHMpCgl7CgkJc3pbUk9XU10gPSByb3dzOwoJCXN6W0NPTFNdID0gY29sczsKCX0KCQoJaW5saW5lIGludCogb3BlcmF0b3JbXShpbnQgbikgewoJCXJldHVybiAmdltuKnN6W1JPV1NdXTsKCX0KfTsKCmludCBtYWluKCkgewoJTXlfdmVjIHYgezIsIDJ9OwoJZm9yIChhdXRvIGkgPSAwOyBpIDwgMjsgKytpKQoJCWZvciAoYXV0byBqID0gMDsgaiA8IDI7ICsraikKCQkJdltpXVtqXSA9IGkgKiAyICsgajsKCQoJZm9yIChhdXRvIGkgPSAwOyBpIDwgMjsgKytpKSB7CgkJZm9yIChhdXRvIGogPSAwOyBqIDwgMjsgKytqKQoJCQlzdGQ6OmNvdXQgPDwgdltpXVtqXSA8PCAnICc7CgkJc3RkOjpjb3V0IDw8ICdcbic7Cgl9CglyZXR1cm4gMDsKfQ==