QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#682720 | #8819. CNOI Knowledge | RainingLove | WA | 49ms | 4608kb | C++23 | 1.1kb | 2024-10-27 17:04:39 | 2024-10-27 17:04:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
int sameTo[10003];
int ans[10003];
map<pair<int,int>,int> mp;
int ask(int l,int r) {
if(mp.find({l,r})!=mp.end()) return mp[{l,r}];
cout<<"? "<<l<<" "<<r<<endl;
int d;
cin>>d;
return mp[{l,r}]=d;
}
void solve() {
cin>>n;
for(int i=2;i<=n;i++) {
int l=1,r=i-1;
int ans=0;
while(l<=r) {
int mid=l+r>>1;
if(ask(mid,i-1)+(i-1-mid+1)+1==ask(mid,i)) {
r=mid-1;
}
else {
ans=mid;//mid到i,i不是第一次出现
l=mid+1;
}
}
sameTo[i]=ans;
}
int c=0;
for(int i=1;i<=n;i++) {
if(sameTo[i]) ans[i]=ans[sameTo[i]];
else ans[i]=++c;
}
cout<<"! ";
for(int i=1;i<=n;i++) {
cout<<ans[i]<<" ";
}cout<<endl;
}
/*
1 2 3 3
*/
signed main() {
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t=1;
// cin>>t;
while(t--)
solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
input:
12 1 3 6 3 6 10 10 15 6 10 21 15 27 15 20 10 14 3 6 6 9 20 26 34 34 43 14 19 6 9 3 5 1 2 25 8 5 19 25 9 13 19
output:
? 1 1 ? 1 2 ? 1 3 ? 2 3 ? 2 4 ? 1 4 ? 2 5 ? 1 5 ? 3 5 ? 3 6 ? 1 6 ? 3 7 ? 1 7 ? 2 6 ? 2 7 ? 4 7 ? 4 8 ? 6 7 ? 6 8 ? 5 7 ? 5 8 ? 4 9 ? 2 8 ? 2 9 ? 1 8 ? 1 9 ? 5 9 ? 5 10 ?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