結果

問題 No.282 おもりと天秤(2)
ユーザー cielciel
提出日時 2018-01-01 15:28:17
言語 Crystal
(1.11.2)
結果
AC  
実行時間 1,582 ms / 5,000 ms
コード長 418 bytes
コンパイル時間 20,924 ms
コンパイル使用メモリ 256,480 KB
実行使用メモリ 24,408 KB
平均クエリ数 211.21
最終ジャッジ日時 2023-09-24 01:38:10
合計ジャッジ時間 34,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,664 KB
testcase_01 AC 24 ms
23,376 KB
testcase_02 AC 22 ms
24,036 KB
testcase_03 AC 21 ms
23,820 KB
testcase_04 AC 21 ms
24,060 KB
testcase_05 AC 26 ms
23,412 KB
testcase_06 AC 25 ms
24,024 KB
testcase_07 AC 21 ms
24,348 KB
testcase_08 AC 24 ms
23,640 KB
testcase_09 AC 21 ms
24,036 KB
testcase_10 AC 413 ms
23,340 KB
testcase_11 AC 1,313 ms
24,336 KB
testcase_12 AC 413 ms
24,288 KB
testcase_13 AC 654 ms
23,364 KB
testcase_14 AC 1,135 ms
24,288 KB
testcase_15 AC 1,356 ms
23,784 KB
testcase_16 AC 88 ms
23,652 KB
testcase_17 AC 600 ms
24,408 KB
testcase_18 AC 962 ms
24,336 KB
testcase_19 AC 1,021 ms
23,664 KB
testcase_20 AC 1,551 ms
24,048 KB
testcase_21 AC 1,515 ms
24,264 KB
testcase_22 AC 1,582 ms
24,408 KB
testcase_23 AC 20 ms
24,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def perform(start,q)
	puts "? "+q.join(" ")
	STDOUT.flush
	f=true
	gets.not_nil!.split.each_with_index(0){|e,i|
		if e==">"
			f=false
			A.swap(i*2+0+start,i*2+1+start)
		end
	}
	f	
end
def g(s,e,pad) A[s...e].each_slice(2).flat_map{|e|e}.to_a+[0]*pad end

N=gets.not_nil!.to_i
A=(1..N).to_a
loop{break if perform(0,N%2==0?g(0,N,N) : g(0,N-1,N+1)) || perform(1,N%2==0?g(1,N-1,N+2) : g(1,N,N+1))}
puts "! "+A.join(" ")
0