結果

問題 No.1169 Row and Column and Diagonal
ユーザー sahiyasahiya
提出日時 2020-12-09 14:42:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 111,036 KB
実行使用メモリ 4,664 KB
最終ジャッジ日時 2023-10-19 04:52:41
合計ジャッジ時間 3,357 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 6 ms
4,348 KB
testcase_08 AC 8 ms
4,348 KB
testcase_09 AC 11 ms
4,352 KB
testcase_10 AC 18 ms
4,592 KB
testcase_11 AC 19 ms
4,632 KB
testcase_12 AC 20 ms
4,656 KB
testcase_13 AC 20 ms
4,660 KB
testcase_14 AC 21 ms
4,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 500;

int N;

int ans[MAX_N][MAX_N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;

    for (int i = 0; i < N; i++) {
        for (int n = 1; n <= N; n++) {
            ans[i][((N + 1 - n) % N + 2 * i) % N] = n;
        }
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }

    return 0;
}
0