結果

問題 No.1169 Row and Column and Diagonal
ユーザー siro53siro53
提出日時 2020-08-24 16:52:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,705 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 198,540 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 03:34:43
合計ジャッジ時間 3,415 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 6 ms
6,940 KB
testcase_09 AC 9 ms
6,940 KB
testcase_10 AC 15 ms
6,940 KB
testcase_11 AC 16 ms
6,940 KB
testcase_12 AC 17 ms
6,940 KB
testcase_13 AC 17 ms
6,944 KB
testcase_14 AC 17 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector ans(N, vector<int>(N));
    for(int i = 0; i < N; i++) {
        int now = (2 * i + 1) % N;
        if(now == 0) {
            now = N;
        }
        for(int j = 0; j < N; j++) {
            int tmp = (now - j + N) % N;
            if(tmp == 0) {
                tmp = N;
            }
            ans[i][j] = tmp;
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            cout << ans[i][j] << " \n"[j == N - 1];
        }
    }
}
0