結果
問題 | No.3092 Tired Queen |
ユーザー |
|
提出日時 | 2025-02-24 20:20:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 2,292 bytes |
コンパイル時間 | 3,869 ms |
コンパイル使用メモリ | 225,616 KB |
実行使用メモリ | 17,920 KB |
最終ジャッジ日時 | 2025-02-24 20:21:03 |
合計ジャッジ時間 | 7,772 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
ソースコード
#include <bits/stdc++.h> #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--) using namespace std; using ll = long long; using ld = long double; const double pi = 3.141592653589793; const long long inf = 2 * 1e9; const long long linf = 4 * 1e18; const ll mod1 = 1000000007; const ll mod2 = 998244353; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } // atcoder #include <atcoder/all> using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; vector<pair<ll, ll>> base = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; void calc(ll &x, ll &y, ll B) { if (x > B) { x--; y++; } if (y > B) { y--; x++; } return; } int main(int argc, char **argv) { ////////////////// ios::sync_with_stdio(false); cin.tie(nullptr); ////////////////// ll N; cin >> N; vector<vector<ll>> G(N, vector<ll>(N)), nG(N, vector<ll>(N)); ll now = N; ll x, y; ll temp = 1; rep(i, 0, N / 2) { x = i; y = i; G.at(x).at(y) = temp; temp++; x++; rep(j, 0, 2 * (N - 2 * i) - 3) { G.at(x).at(y) = temp; temp++; swap(x, y); G.at(x).at(y) = temp; temp++; if (j % 2 == 0) { y++; } else { x++; } calc(x, y, N - 1 - i); } G.at(x).at(y) = temp; temp++; } if (N % 2 == 1) { G.at(N / 2).at(N / 2) = N * N; } rep(i, 0, N) { rep(j, 0, N) { if (min(min(i, j), min(N - 1 - i, N - 1 - j)) % 2 == 1) { nG.at(i).at(j) = G.at(N - 1 - i).at(N - 1 - j); } else { nG.at(i).at(j) = G.at(i).at(j); } } } rep(i, 0, N) { rep(j, 0, N) { cout << nG.at(i).at(j) << " "; } cout << endl; } }