QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#407391 | #8267. Staring Contest | Physics212303 | 0 | 5ms | 3768kb | C++17 | 711b | 2024-05-08 17:14:56 | 2024-05-08 17:14:58 |
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int n; cin>>n;
vector<int> a(n),p(n);
iota(p.begin(),p.end(),0);
shuffle(p.begin(),p.end(),mt19937(random_device()()));
auto ask=[&](int x,int y){
cout<<"? "<<x<<' '<<y<<endl;
int r; cin>>r; return r;
};
int x=-1,y=-1,w=-1;
for(int i:p){
if(x<0)x=i;
else if(y<0)y=i,w=ask(x,y);
else{
int o=ask(x,i),t;
if(w<o)a[y]=w,y=i,w=o;
else if(w>o)a[i]=o;
else if((t=ask(y,i))==w)a[i]=a[x]=a[y]=w,x=y=-1;
else a[x]=w,x=y,y=i,w=t;
}
}
if(~x)a[x]; if(~y)a[y]=w;
cout<<"! ";
for(int i:a)cout<<i+1<<' ';
cout<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3600kb
input:
2
output:
? 1 0
result:
wrong answer Integer 0 violates the range [1, 2]
Subtask #2:
score: 0
Wrong Answer
Test #58:
score: 0
Wrong Answer
time: 1ms
memory: 3768kb
input:
1000 658 104 100 36 658 697 33 204 317 867 450 70 509 391 324 51 232 330 574 484 288 552 524 646 152 60 601 482 62 384 595 171 117 527 897 453 956 936 326 795 955 465 956 962 401 862 472 593 163 422 837 428 962 966 877 857 577 57 829 686 40 144 355 366 10 827 395 553 894 922 183 182 102 374 333 225 ...
output:
? 658 956 ? 658 104 ? 658 100 ? 658 36 ? 658 697 ? 956 697 ? 956 33 ? 956 204 ? 956 317 ? 956 867 ? 956 450 ? 956 70 ? 956 509 ? 956 391 ? 956 324 ? 956 51 ? 956 232 ? 956 330 ? 956 574 ? 956 484 ? 956 288 ? 956 552 ? 956 524 ? 956 646 ? 956 152 ? 956 60 ? 956 601 ? 956 482 ? 956 62 ? 956 384 ? 956 ...
result:
wrong answer Integer 0 violates the range [1, 1000]
Subtask #3:
score: 0
Wrong Answer
Test #88:
score: 0
Wrong Answer
time: 5ms
memory: 3516kb
input:
1500 654 191 840 747 53 840 1130 1237 174 804 1237 1410 1316 1410 1466 907 1273 312 392 986 440 867 1354 106 156 791 1046 540 748 955 1228 1176 446 842 920 1342 1138 311 565 1325 1087 611 851 281 599 1421 1344 1376 552 93 402 29 1377 1466 1483 426 216 1123 289 1269 899 288 1422 283 996 608 16 1213 3...
output:
? 840 654 ? 840 191 ? 840 1237 ? 840 747 ? 840 53 ? 840 1130 ? 1237 1130 ? 1237 1410 ? 1237 174 ? 1237 804 ? 1237 1466 ? 1410 1466 ? 1410 1316 ? 1410 1488 ? 1466 1488 ? 1466 907 ? 1466 1273 ? 1466 312 ? 1466 392 ? 1466 986 ? 1466 440 ? 1466 867 ? 1466 1354 ? 1466 106 ? 1466 156 ? 1466 791 ? 1466 104...
result:
wrong answer Integer 0 violates the range [1, 1500]