結果

問題 No.1169 Row and Column and Diagonal
ユーザー kotatsugamekotatsugame
提出日時 2020-09-09 18:04:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 64,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-09 11:13:46
合計ジャッジ時間 2,514 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 5 ms
6,944 KB
testcase_07 AC 14 ms
6,940 KB
testcase_08 AC 26 ms
6,940 KB
testcase_09 AC 42 ms
6,944 KB
testcase_10 AC 99 ms
6,944 KB
testcase_11 AC 114 ms
6,944 KB
testcase_12 AC 124 ms
6,940 KB
testcase_13 AC 126 ms
6,940 KB
testcase_14 AC 127 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
int A[500][500];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)A[i][i]=i+1;
	for(int i=0;i<N-1;i++)
	{
		int t=A[i][i];
		for(int j=i+1;j<N;j++)
		{
			while(true)
			{
				bool found=false;
				for(int k=0;k<N;k++)if(A[i][k]==t||A[k][j]==t)
				{
					found=true;
					break;
				}
				if(!found)
				{
					break;
				}
				t=t%N+1;
			}
			A[i][j]=A[j][i]=t;
		}
	}
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)cout<<A[i][j]<<(j+1==N?'\n':' ');
	}
}
0