結果

問題 No.839 Keep Distance and Nobody Explodes
ユーザー rpy3cpprpy3cpp
提出日時 2019-09-08 21:41:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,295 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 170,020 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:45:13
合計ジャッジ時間 4,186 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 6 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 6 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 4 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 5 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int>> V(N, vector<int> (N, 0LL));
    // fill odd numbers
    int k = 1;
    for (int y = 0; y < N / 2; ++y){
        if (y % 2){
            for (int x = N - 1; x >= 0; --x){
                V[y][x] = k;
                k += 2;
            }
        }else{
            for (int x = 0; x < N; ++x){
                V[y][x] = k;
                k += 2;
            }
        }
    }

    // fill even numbers
    k = 2;
    for (int y = N / 2; y < N; ++y){
        if (y % 2){
            for (int x = N / 2 - 1; x >= 0; --x){
                V[y][x] = k;
                k += 2;
            }
            for (int x = N - 1; x >= N / 2; --x){
                V[y][x] = k;
                k += 2;
            }
        }else{
            for (int x = N / 2; x < N; ++x){
                V[y][x] = k;
                k += 2;
            }
            for (int x = 0; x < N / 2; ++x){
                V[y][x] = k;
                k += 2;
            }
        }
    }

    for (int y = 0; y < N; ++y){
        for (int x = 0; x < N - 1; ++x){
            cout << V[y][x] << ' ';
        }
        cout << V[y][N - 1] << '\n';
    }
    return 0;
}
0