QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#773790 | #9783. Duloc Network | ucup-team3564# | WA | 9ms | 37428kb | C++14 | 2.6kb | 2024-11-23 10:20:25 | 2024-11-23 10:20:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],v[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001];
char s[1000001];
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
vector<int> ve[1000001],tmp;
map<vector<int>,int> vi,vee;
long long ggg=0;
long long ask(vector<int> qq)
{
sort(qq.begin(),qq.end());
if(vi[qq]) return vee[qq];
vi[qq]=1;
++ggg;
assert(ggg<=3500);
for(int i=1;i<=a;i++) v[i]=0;
for(int i=0;i<qq.size();i++)
{
v[qq[i]]=1;
}
printf("? ");
fflush(stdout);
for(int i=1;i<=a;i++) printf("%lld",v[i]);
printf("\n");
fflush(stdout);
scanf("%lld",&q);
fflush(stdout);
return vee[qq]=q;
}
int main()
{
// freopen("1.in","r",stdin);
scanf("%lld",&a);
for(int i=1;i<=a;i++) fa[i]=i,ve[i].push_back(i);
for(int i=1;i<=a;i++) d[i]=ask(ve[i]);
st[++cn]=1;
long long all=d[1];
for(int i=2;i<=a;i++)
{
st[++cn]=i;
all+=d[i];
while(1)
{
tmp.clear();
for(int j=1;j<=cn;j++)
{
for(int k=0;k<ve[st[j]].size();k++) tmp.push_back(ve[st[j]][k]);
}
long long nww=ask(tmp);
// cout<<nww<<" "<<all<<"\n";
if(nww==all)
{
break;
}
long long tt=nww,ann=cn-1;
long long ll=1,rr=cn-1;
while(ll<=rr)
{
long long mid=((ll+rr)>>1);
tmp.clear();
for(int j=1;j<=mid;j++)
{
for(int k=0;k<ve[st[j]].size();k++) tmp.push_back(ve[st[j]][k]);
}
for(int j=0;j<ve[st[cn]].size();j++) tmp.push_back(ve[st[cn]][j]);
nww=ask(tmp);
if(nww==all) ll=mid+1;
else rr=mid-1,ann=mid;
}
all=all-ask(ve[st[cn]])-ask(ve[st[ann]]);
for(int j=0;j<ve[st[cn]].size();j++) ve[st[ann]].push_back(ve[st[cn]][j]);
all+=ask(ve[st[ann]]);
long long nx=st[ann];
for(int j=ann;j<cn;j++) st[j]=st[j+1];
st[cn-1]=nx,--cn;
}
}
if(cn>1) printf("! 0");
else printf("! 1");
fflush(stdout);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 36428kb
input:
4 1 3 2 2 2 1 0
output:
? 1000 ? 0100 ? 0010 ? 0001 ? 1100 ? 1110 ? 1111 ! 1
result:
ok Correct answer with 7 queries.
Test #2:
score: 0
Accepted
time: 6ms
memory: 35924kb
input:
2 0 0 0
output:
? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 3 queries.
Test #3:
score: 0
Accepted
time: 9ms
memory: 35780kb
input:
4 1 3 2 2 2 1 0
output:
? 1000 ? 0100 ? 0010 ? 0001 ? 1100 ? 1110 ? 1111 ! 1
result:
ok Correct answer with 7 queries.
Test #4:
score: 0
Accepted
time: 3ms
memory: 37428kb
input:
2 0 0 0
output:
? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 3 queries.
Test #5:
score: -100
Wrong Answer
time: 8ms
memory: 37200kb
input:
50 3 1 1 1 1 4 3 1 1 2 3 3 2 1 2 4 3 1 1 1 2 4 1 3 1 4 3 2 2 2 4 2 2 1 1 2 1 2 4 1 1 3 3 3 6 2 1 3 2 3 4 5 6 7 10 9 7 8 9 11 4 12 13 14 13 12 14 5 4 16 15 14 16 17 15 16 5 17 17 16 17 2 16 15 16 15 14 15 2 14 13 12 13 14 14 14 13 14 13 14 12 12 11 10 9 8 7 7 6 5 4 3 2 1 0
output:
? 10000000000000000000000000000000000000000000000000 ? 01000000000000000000000000000000000000000000000000 ? 00100000000000000000000000000000000000000000000000 ? 00010000000000000000000000000000000000000000000000 ? 00001000000000000000000000000000000000000000000000 ? 000001000000000000000000000000000...
result:
wrong answer Wrong answer.