QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#647695 | #8819. CNOI Knowledge | planckconstant | WA | 9ms | 4732kb | C++20 | 1.3kb | 2024-10-17 15:16:48 | 2024-10-17 15:16:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define double long double
#define INF 1e15
void slove()
{
int n;
cin>>n;
vector<int>a(n+5);
a[1]=1;
int num=1;
map<pair<int,int>,int>b;
for(int i=2;i<=n;i++){
int l=1,r=i;
while(l<r){
int mid=(l+r)/2;
int x1,x2;
cout<<"? "<<mid<<' '<<i<<endl;
cin>>x1;
b[{mid,i}]=x1;
x2=1;
if(mid!=i-1){
if(b[{mid,i-1}]==0){
cout<<"? "<<mid<<' '<<i-1<<endl;
cin>>x2;
b[{mid,i-1}]=x2;
}
x2=b[{mid,i-1}];
}
if((x1-x2)==(i-mid+1)){
r=mid;
}
else{
l=mid+1;
}
}
if(l==1){
a[i]=++num;
}
else{
a[i]=a[l-1];
}
}
cout<<"! ";
for(int i=1;i<=n;i++){
cout<<a[i]<<' ';
}
cout<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
//cin >> t;
while (t--) {
slove();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3596kb
input:
12 3 3 6 6 10 6 3 10 15 10 15 21 10 6 20 15 14 6 3 9 6 14 27 20 34 26 43 34 19 5 3 2 19 14 5 8 25 9 13 19 13
output:
? 1 2 ? 2 3 ? 1 3 ? 2 4 ? 1 4 ? 3 5 ? 3 4 ? 2 5 ? 1 5 ? 3 6 ? 2 6 ? 1 6 ? 4 7 ? 4 6 ? 2 7 ? 3 7 ? 4 8 ? 6 8 ? 6 7 ? 5 8 ? 5 7 ? 5 9 ? 3 9 ? 3 8 ? 2 9 ? 2 8 ? 1 9 ? 1 8 ? 5 10 ? 8 10 ? 8 9 ? 9 10 ? 6 11 ? 6 10 ? 9 11 ? 8 11 ? 6 12 ? 9 12 ? 8 12 ? 7 12 ? 7 11 ! 1 2 3 4 5 6 2 5 7 7 5 6
result:
ok Accepted. 41 queries used.
Test #2:
score: -100
Wrong Answer
time: 9ms
memory: 4732kb
input:
1000 3 2 3 2 5 7 11 7 8 2 7 5 2 11 5 7 3 11 5 3 3 15 5 2 15 11 3 2 19 4 2 17 14 4 3 2 20 4 3 2 15 13 4 3 2 23 9 13 6 15 7 23 11 7 5 3 3 31 11 8 5 3 36 27 11 7 5 2 45 15 3 2 48 39 15 11 5 7 11 7 58 16 5 3 2 59 50 16 11 5 8 69 21 8 2 69 59 20 16 8 5 3 5 79 20 16 8 2 76 67 20 16 8 5 3 5 87 26 8 3 5 88 ...
output:
? 1 2 ? 2 3 ? 2 4 ? 3 4 ? 3 5 ? 2 5 ? 1 5 ? 1 4 ? 3 6 ? 5 6 ? 4 7 ? 4 6 ? 6 7 ? 4 8 ? 6 8 ? 5 8 ? 5 7 ? 5 9 ? 7 9 ? 7 8 ? 8 9 ? 5 10 ? 8 10 ? 9 10 ? 6 11 ? 6 10 ? 9 11 ? 10 11 ? 6 12 ? 9 12 ? 11 12 ? 7 13 ? 7 12 ? 10 13 ? 10 12 ? 12 13 ? 7 14 ? 11 14 ? 11 13 ? 13 14 ? 8 15 ? 8 14 ? 12 15 ? 12 14 ? 1...
result:
wrong answer Too many queries.