結果
問題 |
No.2577 Simple Permutation Guess
|
ユーザー |
|
提出日時 | 2023-12-08 09:16:02 |
言語 | D (dmd 2.109.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 903 bytes |
コンパイル時間 | 4,564 ms |
コンパイル使用メモリ | 148,968 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 251.95 |
最終ジャッジ日時 | 2024-09-27 02:42:19 |
合計ジャッジ時間 | 17,461 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 110 RE * 1 |
ソースコード
import std.stdio; import std.string; import std.conv; import std.algorithm; void answer(int[] ans){ writefln("! %s", ans.to!(string[]).join(" ")); stdout.flush; } int query(int[] ans){ writefln("? %s", ans.to!(string[]).join(" ")); stdout.flush; return readln.chomp.to!int; } void main(){ int n = readln.chomp.to!int; int[] fixed; int min = 0; int max = n - 1; int[] cand; for(auto i = 1; i <= n; i++){ cand ~= i; } while(fixed.length < n - 1){ int c = (min + max + 1) / 2; auto r = query(fixed ~ cand[c] ~ cand[0 .. c] ~ cand[ c + 1 .. $]); final switch(r){ case 1: min = c; break; case 0: max = c - 1; break; case -1: return; } if(min == max){ fixed ~= cand[min]; cand = cand.remove(min); min = 0; max = cast(int)cand.length - 1; } } answer(fixed ~ cand); }