#include #include using namespace std; using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; using ll = long long; using P = pair; using T = tuple; templatebool chmax(T_& a, const T_& b) { if (a < b) { a = b;return true; } else { return false; } } templatebool chmin(T_& a, const T_& b) { if (a > b) { a = b;return true; } else { return false; } } #ifdef LOCAL template ostream& operator<<(ostream& o, const pair& p) { return o << "(" << p.first << ", " << p.second << ")"; } template ostream& operator<<(ostream& o, const tuple& t) { o << "("; apply([&o](auto&&... a) { int c = 0; (((o << (c++ ? ", " : "") << a)), ...); }, t); return o << ")"; } template auto operator<<(ostream& o, const V& v) -> std::enable_if_t && !std::is_same_v, decltype(v.begin(), o)> { o << "{"; int c = 0; for (auto& x : v) o << (c++ ? ", " : "") << x; return o << "}"; } #define dbg(...) cerr<<"["<<#__VA_ARGS__<<"]: ",([](auto&&... a){((cerr<> n >> m >> kk; vector a(m); int k = sqrt(m); if (k * k < m)k++; dbg(k); iota(a.begin(), a.end(), 1); vector ans(n, vector(n)); for (int i = 0; i < n; i++) { auto b = a; for (int j = 0; j < m; j++) { b[j] = a[(j + k) % m]; } a = b; for (int j = 0; j < (n / m); j++) { for (int l = 0; l < m; l++) { ans[i][l + j * m] = a[l]; } } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << ans[i][j] << ' '; }cout << "\n"; } // bool ok = true; // for (int i = 0; i < n - kk + 1; i++) { // for (int j = 0; j < n - kk + 1; j++) { // set st; // for (int di = i; di < i + kk; di++) { // for (int dj = j; dj < j + kk; dj++) { // st.emplace(ans[di][dj]); // } // } // if ((int)st.size() != m)ok = false; // } // } // cout << (ok ? "Yes" : "No") << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); } }