QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#117145 | #4926. Where Is the Root? | elainagrey | 0 | 6ms | 3552kb | C++14 | 620b | 2023-06-30 14:37:47 | 2023-06-30 14:37:48 |
Judging History
answer
// where is the root
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
int n,a,b,adj[510];
vector<int> v;
char S[10];
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b;
adj[a]++;adj[b]++;
}
rep(i,n)if(adj[i]==1)v.pb(i);
rep(i,n)if(adj[i]!=1)v.pb(i);
int s=0,e=n,mid;
while(e-s>1){
mid=(e+s)/2;
cout<<"? "<<mid<<' ';
rep(i,mid)cout<<v[i]<<' ';
cout<<endl;cout.flush();
cin>>S;
if(S[0]=='N')s=mid;
else e=mid;
}
cout<<"! "<<v[e-1]<<endl;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3376kb
input:
7 4 1 1 2 4 3 3 5 3 6 4 7 NO
output:
? 3 2 5 6 ? 5 2 5 6 0 1
result:
wrong output format Unexpected end of file - int32 expected
Subtask #2:
score: 0
Wrong Answer
Test #24:
score: 10
Accepted
time: 1ms
memory: 3552kb
input:
30 1 15 29 30 1 4 7 28 29 17 1 26 26 7 12 5 27 13 3 7 27 1 21 15 9 22 22 5 24 27 19 1 25 30 22 27 6 15 16 13 18 2 27 10 27 30 20 26 8 15 18 8 14 1 27 23 11 3 YES NO NO NO YES
output:
? 15 2 4 6 9 10 11 12 14 16 17 19 20 21 23 24 ? 7 2 4 6 9 10 11 12 ? 11 2 4 6 9 10 11 12 14 16 17 19 ? 13 2 4 6 9 10 11 12 14 16 17 19 20 21 ? 14 2 4 6 9 10 11 12 14 16 17 19 20 21 23 ! 23
result:
ok OK
Test #25:
score: 0
Accepted
time: 1ms
memory: 3384kb
input:
30 15 16 8 6 19 2 26 17 30 15 26 4 1 6 1 23 15 1 29 25 21 3 12 1 2 24 29 22 9 1 3 10 27 28 5 12 20 5 14 7 5 26 7 18 10 23 1 28 3 11 7 1 19 23 13 23 29 30 YES YES NO NO YES
output:
? 15 4 8 9 11 13 14 16 17 18 20 21 22 24 25 27 ? 7 4 8 9 11 13 14 16 ? 3 4 8 9 ? 5 4 8 9 11 13 ? 6 4 8 9 11 13 14 ! 14
result:
ok OK
Test #26:
score: -10
Wrong Answer
time: 0ms
memory: 3264kb
input:
30 19 7 14 27 22 18 15 19 1 18 27 23 21 28 19 24 25 10 27 3 23 7 9 26 20 4 7 9 12 19 6 19 23 17 18 5 5 8 21 25 10 30 9 1 5 29 2 7 12 10 11 6 4 10 26 13 5 16
output:
? 15 2 3 8 11 13 14 15 16 17 20 22 24 28 29 0
result:
wrong output format Unexpected end of file - int32 expected
Subtask #3:
score: 0
Wrong Answer
Test #54:
score: 0
Wrong Answer
time: 6ms
memory: 3264kb
input:
500 419 133 44 225 391 269 419 461 293 347 108 31 110 363 423 257 321 155 498 87 180 492 251 5 357 30 341 172 275 109 372 446 286 336 208 339 162 320 138 103 129 219 62 141 359 286 130 238 470 460 418 48 210 358 429 13 323 143 382 415 406 394 309 175 325 170 128 108 6 113 363 17 470 457 7 224 288 48...
output:
? 250 2 3 7 8 10 11 12 13 15 16 19 24 26 28 29 33 34 36 37 38 39 40 41 42 43 45 46 47 50 53 54 55 57 58 64 65 67 68 69 70 71 72 73 74 75 76 77 78 79 80 82 83 85 86 88 95 96 99 100 109 110 112 114 117 119 121 122 123 124 126 129 134 135 138 140 144 148 149 150 152 153 154 155 158 164 165 167 168 169 ...
result:
wrong output format Unexpected end of file - int32 expected