結果

問題 No.1169 Row and Column and Diagonal
ユーザー simkarensimkaren
提出日時 2020-09-29 14:30:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 3,924 ms
コンパイル使用メモリ 187,464 KB
実行使用メモリ 4,448 KB
最終ジャッジ日時 2023-09-16 22:55:00
合計ジャッジ時間 3,516 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 14 ms
4,380 KB
testcase_10 AC 24 ms
4,376 KB
testcase_11 AC 26 ms
4,380 KB
testcase_12 AC 26 ms
4,376 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 28 ms
4,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main(void){
	int N; cin >> N;
	vector<vector<int>> res(N, vector<int>(N, 0));
	map<int, int> f;
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j){
			if ((i + j) % 2 == 0){
				res[i][j] = (i + j) / 2 + 1;
				f[(i + j) % N] = res[i][j];
			}
		}
	}
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			if (res[i][j] == 0)
				res[i][j] = f[(i + j) % N];
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			cout << res[i][j] << (j == N - 1 ? "\n" : " ");
	return 0;
}
0