QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#684945 | #7161. Guessing Game | OccDreamer | 0 | 101ms | 6000kb | C++14 | 2.5kb | 2024-10-28 16:43:13 | 2024-10-28 16:43:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int B = 32;
const int MAXN = 1e5 + 5;
int a[MAXN];
int p, n, subsum[MAXN], dep[MAXN];
int sum, bel[MAXN], idx[MAXN], b[MAXN];
bool mark[MAXN];
pair<int,int> c[MAXN];
mt19937 rnd(time(0));
inline void build(int p, int l, int r){
subsum[p]=r-l+1;
if(l==r) return dep[p]=1, void();
int mid=(l+r)>>1;
build(p<<1,l,mid), build(p<<1|1,mid+1,r); dep[p]=dep[p<<1]+1;
return ;
}
inline int add(int p, int l, int r, int pos){
subsum[p]--; int res=0;
if(subsum[p]==0) res=dep[p];
if(l==r) return res;
int mid=(l+r)>>1;
if(pos<=mid) res=max(add(p<<1,l,mid,pos),res);
else res=max(add(p<<1|1,mid+1,r,pos),res);
return res;
}
inline void solve1(){
cout << 7 << endl; int sum=0;
for(int i=0;i<B;++i) bel[i]=i/2;
for(int i=1;i<=n-B;++i){
int x;
cin >> x; sum+=x, sum%=65536;
cout << 7 << endl; mark[x]=1, a[x]=7;
}
int tot=0;
for(int i=0;i<n;++i){
if(mark[i]) continue;
idx[i]=tot; b[tot]=i; ++tot;
}
build(1,0,B-1);
// cerr << "sum=" << sum << endl;
for(int i=1;i<B;++i){
int x;
cin >> x;
int t=add(1,0,B-1,idx[x]);
// cerr << "t=" << t << endl;
if(t>1) cout << t+1 << endl, a[x]=t+1;
else{
if((sum>>bel[idx[x]])&1) t=2;
cout << t << endl, a[x]=t;
}
}
return ;
}
inline void solve2(){
for(int i=0;i<n;++i) cin >> a[i];
int tot7=0;
for(int i=0;i<n;++i) tot7+=a[i]==7;
if(n-tot7==B){
int tot=0;
for(int i=0;i<n;++i)
if(a[i]==7) continue;
else c[++tot]=make_pair(max(a[i],2),i);
int l=1, r=B, now=6;
while(l+1<r){
int mid=(l+r)>>1, L=-1, R=-1;
for(int i=l;i<=mid;++i) L=(c[i].first==now?c[i].second:L);
for(int i=mid+1;i<=r;++i) R=(c[i].first==now?c[i].second:R);
// if(L==-1 && R==-1) exit(1);
if(L!=-1 && R!=-1){
cout << L << ' ' << R << endl;
return ;
}
if(L==-1) r=mid-1;
else l=mid+1; --now;
}
cout << c[l].second << ' ' << c[r].second << endl;
}
else{
int s=0, tot=0, ss=0;
for(int i=0;i<n;++i) s+=i, s%=65536;
for(int i=0;i<n;++i){
if(a[i]==7) continue;
(s+=65536-i%65536)%=65536;
if(a[i]==1) ++tot;
if(a[i]==2) ss|=1<<tot, ++tot;
}
ss%=65536;
// cerr << "sum=" << ss << endl;
(s+=65536-ss)%=65536;
// cerr << "lol" << endl;
if(s+(1<<16)>=n) cout << s << ' ' << s << endl;
else cout << s << ' ' << s+(1<<16) << endl;
}
return ;
}
int main(){
// freopen("guess.in","r",stdin);
// freopen("guess.out","w",stdout);
cin >> p >> n;
if(p==1) solve1();
else solve2();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 101ms
memory: 6000kb
input:
1 100000 12606 98679 1143 27998 32709 12689 96311 76575 72650 78703 62559 98406 20833 67597 18721 7007 37493 4265 64463 74773 99034 72638 1056 53975 99258 55401 24025 58380 25917 34732 15691 539 97052 60642 47161 10744 2593 58625 15172 39492 11676 19724 81135 15030 87595 85629 4673 1135 47214 47939 ...
output:
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ...
input:
2 100000 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7...
output:
20581 20581
result:
wrong answer Token "WA" doesn't correspond to pattern "OK"