結果

問題 No.3092 Tired Queen
ユーザー seren
提出日時 2025-04-06 15:51:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 3,367 bytes
コンパイル時間 4,647 ms
コンパイル使用メモリ 257,296 KB
実行使用メモリ 29,568 KB
最終ジャッジ日時 2025-04-06 15:52:00
合計ジャッジ時間 8,838 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

//*
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
// using mint = modint1000000007;
//*/

using ll = long long;
using i128 = __int128_t;
using pll = pair<ll, ll>;
using tlll = tuple<ll, ll, ll>;
using ld = long double;
const int INF = 1000100100;
const ll INFF = 1000100100100100100LL;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(i, n) for (ll i = 0; i < ll(n); i++)
#define rep2(i, l, r) for (ll i = ll(l); i < ll(r); i++)
#define rep3(i, l, r, d) for (ll i = ll(l); (d) > 0 ? i < ll(r) : i > ll(r); i += d)
#define rep(...) overload4(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define yesno(f) cout << (f ? "Yes" : "No") << endl;
#define YESNO(f) cout << (f ? "YES" : "NO") << endl;
#define all(a) (a).begin(), (a).end()
#define popc(x) __builtin_popcountll(ll(x))

template <typename S, typename T>
ostream &operator<<(ostream &os, const pair<S, T> &p) {
    return os << p.first << ' ' << p.second;
}

template <typename T>
void printvec(const vector<T> &v) {
    int n = v.size();
    rep(i, n) cout << v[i] << (i == n - 1 ? "" : " ");
    cout << '\n';
}

template <typename T>
void printvect(const vector<T> &v) {
    for (auto &vi : v) cout << vi << '\n';
}

template <typename T>
void printvec2(const vector<vector<T>> &v) {
    for (auto &vi : v) printvec(vi);
}

template <typename S, typename T>
bool chmax(S &x, const T &y) {
    return (x < y) ? (x = y, true) : false;
}

template <typename S, typename T>
bool chmin(S &x, const T &y) {
    return (x > y) ? (x = y, true) : false;
}

#ifdef LOCAL  // https://zenn.dev/sassan/articles/19db660e4da0a4
#include "cpp-dump-main/dump.hpp"
#define dump(...) cpp_dump(__VA_ARGS__)
CPP_DUMP_DEFINE_DANGEROUS_EXPORT_OBJECT(val());
#else
#define dump(...)
#endif

struct io_setup {
    io_setup() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;
void solve() {
    int n;
    cin >> n;
    vector<vector<int>> ans(n, vector<int>(n));
    int id = 0;
    auto dfs = [&](auto dfs, int z) -> void {
        dump(z);
        if (z == 0) return;
        if (z == 1) {
            ans[n / 2][n / 2] = id + 1;
            return;
        }
        int res = (z - 1) * 4;
        vector<int> num;
        for (int i = 1; i <= res; i += 4) {
            num.push_back(i);
            num.push_back(i + 1);
        }
        for (int i = 3; i <= res; i += 4) {
            num.push_back(i);
            num.push_back(i + 1);
        }
        int x = (n - z) / 2;
        dump(x);
        vector<pll> v;
        rep(i, z) {
            v.emplace_back(x, x + i);
        }
        rep(i, 1, z - 1) {
            v.emplace_back(x + i, x + z - 1);
        }
        rep(i, 1, z) {
            v.emplace_back(x + i, x);
        }
        rep(i, 1, z) {
            v.emplace_back(x + z - 1, x + i);
        }
        dump(v);
        rep(i, v.size()) {
            ans[v[i].first][v[i].second] = id + num[i];
        }
        dump(v, num);
        id += res;
        dfs(dfs, z - 2);
        return;
    };
    dfs(dfs, n);
    printvec2(ans);
}
int main() {
    int t;
    // cin >> t;
    t = 1;
    while (t--) {
        solve();
    }
}
0