結果

問題 No.839 Keep Distance and Nobody Explodes
コンテスト
ユーザー zelda_master
提出日時 2026-09-19 18:22:43
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 731 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 325 ms
コンパイル使用メモリ 73,048 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-19 18:22:46
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdio>

using namespace std;

const int N = 310;

int n, a[N][N];

int main() {
    // freopen("safe.in", "r", stdin);
    // freopen("safe.out", "w", stdout);

    scanf("%d", &n);

    for (int i = 1; i <= n * n / 2; ++i) {
        int row = (i + n / 2 - 1) / (n / 2), col = ((i - 1) % (n / 2) + 1) * 2 - 1;
        a[row][col] = i;
    }
    for (int i = n * n / 2 + 1; i <= n * n; ++i) {
        int num = i - n * n / 2;
        int row = (num + n / 2 - 1) / (n / 2), col = ((num - 1) % (n / 2) + 1) * 2;
        a[row][col] = i;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            printf("%d%c", a[i][j], " \n"[j == n]);
        }
    }

    return 0;
}
0