QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#261565 | #7804. Intersegment Activation | FHQY_WWW# | WA | 1ms | 3384kb | C++20 | 2.6kb | 2023-11-22 23:54:47 | 2023-11-22 23:54:47 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define double long double
#define lowbit(x) x&(-x)
#define fastios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define el puts("")
#define udm unordered_map<int,int>
#define set_0(a) memset(&a,0,sizeof(a))
#define set_unint(a) memset(&a,-1,sizeof(a))
using namespace std;
//define_var
const int M=2e5+9,inf=1e18;
bool isok[M],sign[M];
int n,k;
int pro;
//define_var
//function_begin
//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*10+c-'0',c=getchar();
// return x*f;
//}
//void write(int x)
//{
// if(x<0) putchar('-'),x=-x;
// if(x>9) write(x/10);
// putchar(x%10+'0');
//}
int read(int i,int j)
{
cout<<i<<" "<<j<<endl;
int x;
cin>>x;
return x;
}
bool check(int x)
{
for(int i=0;i<(1<<(n-x));i++)
isok[i]=0;
int now=0;
pro=read(x,x);
if(pro==n) return true;
if(k!=pro)
{
if(pro==k-1)
{
k=read(x,x);
if(k==n) return true;
}
else
k=pro;
if(pro==n)
return true;
else
return false;
}
isok[now]=1;
k=pro;
while(true)
{
bool flag=1;
for(int i=0;i<(1<<(n-x));i++)
flag&=isok[i];
if(flag)
return false;
for(int i=0;i<(1<<(n-x));i++)
{
if(isok[i]) continue;
int ps=-1,cnt=0;
int c1=now,c2=i;
for(int j=0;j<(n-x);j++)
{
if(c1%2==c2%2)
{
c1/=2,c2/=2;
continue;
}
cnt++;
ps=j;
c1/=2,c2/=2;
}
if(cnt==1)
{
isok[i]=1;
pro=read(x,n-ps);
if(pro==n) return true;
if(pro!=k)
{
for(int t=x+1;t<n;t++)
{
if(sign[t]) continue;
pro=read(t,t);
if(pro!=k)
{
if(pro==k-1)
{
k=read(t,t);
sign[t]=1;
}
else
{
sign[t]=1;
k=pro;
}
}
k=pro;
}
}
k=pro;
pro=read(x,x);
if(pro==n) return true;
now=i;
if(k!=pro)
{
if(pro==k-1)
{
k=read(x,x);
if(k==n)
return true;
}
else
k=pro;
if(pro==n)
return true;
else
return false;
}
k=pro;
break;
}
}
}
return false;
}
//function_end
//solve_begin
void solve()
{
cin>>n>>k;
if(k==n)
return;
for(int i=1;i<=n;i++)
{
if(sign[i])
continue;
if(check(i))
return;
sign[i]=1;
}
// read(n,n);
return;
}
//solve_end
//main_begin
signed main()
{
// fastios
int T=1;
// cin>>T;
while(T--)
solve();
}
//main_end
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3340kb
input:
3 0 0 0 0 0 0 0 1 1 2 3
output:
1 1 1 3 1 1 1 2 1 1 1 3 1 1 2 2 2 3 2 2
result:
ok OK, 10 queries
Test #2:
score: 0
Accepted
time: 0ms
memory: 3372kb
input:
1 0 1
output:
1 1
result:
ok OK, 1 queries
Test #3:
score: 0
Accepted
time: 0ms
memory: 3384kb
input:
2 1 2
output:
1 1
result:
ok OK, 1 queries
Test #4:
score: 0
Accepted
time: 0ms
memory: 3384kb
input:
2 0 0 1 0 1 2
output:
1 1 1 2 1 1 1 1 2 2
result:
ok OK, 5 queries
Test #5:
score: 0
Accepted
time: 0ms
memory: 3372kb
input:
2 0 1 2
output:
1 1 2 2
result:
ok OK, 2 queries
Test #6:
score: 0
Accepted
time: 0ms
memory: 3360kb
input:
2 0 0 1 2
output:
1 1 1 2 1 1
result:
ok OK, 3 queries
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3380kb
input:
3 0 0 1 1 1 1 2 1 2
output:
1 1 1 3 2 2 1 1 1 2 1 1 3 3 3 3
result:
wrong answer format Unexpected end of file - int32 expected