QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#773761 | #9783. Duloc Network | ucup-team3564# | WA | 18ms | 53860kb | C++14 | 2.6kb | 2024-11-23 10:16:57 | 2024-11-23 10:16:57 |
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;
long long ask(vector<int> qq)
{
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 q;
}
int main()
{
// freopen("1.in","r",stdin);
srand((unsigned)(time(0)^(*new int)));
fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
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: 15ms
memory: 53548kb
input:
4 1 3 2 2 2 2 3 1 2 2 1 1 2 2 1 1 0 0 2 1 0 0
output:
? 1000 ? 0100 ? 0010 ? 0001 ? 1100 ? 1100 ? 0100 ? 1000 ? 1100 ? 1100 ? 1110 ? 1110 ? 0010 ? 1100 ? 1110 ? 1110 ? 1111 ? 1111 ? 0001 ? 1110 ? 1111 ? 1111 ! 1
result:
ok Correct answer with 22 queries.
Test #2:
score: 0
Accepted
time: 11ms
memory: 53860kb
input:
2 0 0 0
output:
? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 3 queries.
Test #3:
score: 0
Accepted
time: 15ms
memory: 50756kb
input:
4 1 3 2 2 2 2 3 1 2 2 1 1 2 2 1 1 0 0 2 1 0 0
output:
? 1000 ? 0100 ? 0010 ? 0001 ? 1100 ? 1100 ? 0100 ? 1000 ? 1100 ? 1100 ? 1110 ? 1110 ? 0010 ? 1100 ? 1110 ? 1110 ? 1111 ? 1111 ? 0001 ? 1110 ? 1111 ? 1111 ! 1
result:
ok Correct answer with 22 queries.
Test #4:
score: 0
Accepted
time: 18ms
memory: 51932kb
input:
2 0 0 0
output:
? 10 ? 01 ? 11 ! 0
result:
ok Correct answer with 3 queries.
Test #5:
score: -100
Wrong Answer
time: 13ms
memory: 51916kb
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 4 3 7 10 9 8 7 1 8 10 9 9 8 1 9 10 9 9 1 9 10 11 4 3 1 4 11 11 4 9 11 11 12 13 14 13 12 2 11 12 14 14 5 4 3 1 4 14 5 4 1 5 14 14 5 12 14 14 16 16 3 14 16 16 15 15 2 16 15 15 14 14 1 ...
output:
? 10000000000000000000000000000000000000000000000000 ? 01000000000000000000000000000000000000000000000000 ? 00100000000000000000000000000000000000000000000000 ? 00010000000000000000000000000000000000000000000000 ? 00001000000000000000000000000000000000000000000000 ? 000001000000000000000000000000000...
result:
wrong answer Wrong answer.