結果
| 問題 |
No.2577 Simple Permutation Guess
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-12-20 23:19:10 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
QLE
|
| 実行時間 | - |
| コード長 | 1,018 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 30,720 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 251.96 |
| 最終ジャッジ日時 | 2024-09-27 10:14:46 |
| 合計ジャッジ時間 | 12,771 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 110 QLE * 1 |
ソースコード
#include <stdio.h>
int main () {
int n = 0;
int ret = 0;
int res = 0;
int q[400] = {};
int rem[400] = {};
res = scanf("%d", &n);
for (int i = 0; i < n; i++) {
rem[i] = i+1;
}
for (int i = 0; i < n; i++) {
int idx[2] = { 0, n-i };
while (idx[1]-idx[0] > 1) {
int nxt = (idx[0]+idx[1])/2;
printf("?");
for (int j = 0; j < i; j++) {
printf(" %d", q[j]);
}
printf(" %d", rem[nxt]);
for (int j = 0; j < nxt; j++) {
printf(" %d", rem[j]);
}
for (int j = nxt+1; j < n-i; j++) {
printf(" %d", rem[j]);
}
printf("\n");
fflush(stdout);
res = scanf("%d", &ret);
if (ret > 0) {
idx[0] = nxt;
} else {
idx[1] = nxt;
}
}
q[i] = rem[idx[0]];
for (int j = idx[0]; j < n-i-1; j++) {
rem[j] = rem[j+1];
}
}
printf("!");
for (int j = 0; j < n; j++) {
printf(" %d", q[j]);
}
printf("\n");
fflush(stdout);
return 0;
}
chro_96