結果

問題 No.1169 Row and Column and Diagonal
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-07 00:23:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 17,468 KB
最終ジャッジ日時 2023-09-18 09:46:12
合計ジャッジ時間 4,417 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,168 KB
testcase_01 AC 84 ms
15,168 KB
testcase_02 AC 80 ms
15,044 KB
testcase_03 AC 84 ms
15,264 KB
testcase_04 AC 81 ms
15,080 KB
testcase_05 AC 84 ms
15,260 KB
testcase_06 AC 95 ms
15,540 KB
testcase_07 AC 110 ms
16,012 KB
testcase_08 AC 127 ms
15,900 KB
testcase_09 AC 149 ms
16,284 KB
testcase_10 AC 201 ms
16,924 KB
testcase_11 AC 213 ms
17,400 KB
testcase_12 AC 214 ms
17,456 KB
testcase_13 AC 221 ms
17,252 KB
testcase_14 AC 218 ms
17,468 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#順列入れ替えの特徴を見るためにコードで遊んでます。奇数の時だけ上手くいくコードはできたが偶数が変だw
def f(n)
	as=[]
	n.times{
		as<<Array.new(n,0)
	}
	
	ps=[]
	
	ps=(1.step(n-1,2).to_a)+(0.step(n-1,2).to_a)

	n.times{|i|
		s=ps.index(i)
		n.times{|j|
			as[(i+j)%n][ps[(s+j)%n]]=i+1
		}
	}
	n.times{|y|
		puts as[y].join(" ")
	}
end
f(gets.to_i)
0