QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#261031 | #7804. Intersegment Activation | Geospiza# | WA | 1ms | 3724kb | C++20 | 1.9kb | 2023-11-22 17:28:43 | 2023-11-22 17:28:45 |
Judging History
answer
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define Ma 1000005
#define G 3
#define N 11
#define pb push_back
#define L (1<<21)
#define PLL pair<ll,ll>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
using namespace std;
ll n;
vector <ll> dfs(ll cnt,vector <ll> v)
{
if (cnt==0)
return v;
ll lim=v.size();
ll be=v.back();
vector <ll> ans=v;
for (auto z:v)
ans.pb(z^lim^be);
return dfs(cnt-1,ans);
}
ll tot=0;
ll rd(ll l,ll r)
{
tot++;
assert(tot<=2500);
cout<<l<<" "<<r<<endl;
ll ans;
cin>>ans;
return ans;
}
ll all;
ll sum(ll x)
{
ll ans=0;
while (x!=1)
x>>=1;ans++;
return ans;
}
void go(ll l,ll r)
{
if (l>r)
return ;
vector <ll> v;
rd(l,l);
ll p=rd(l,l);
if (p!=all)
{
for (ll i=l;i<=r;i++)
{
ll ne=rd(i,i);
rd(i,i);
if (ne==p+1)
{
all--;
go(l,i-1),go(i+1,r);
return;
}
}
}
v.pb(0);
v=dfs(r-l+1,v);
for (ll i=1;i<v.size();i++)
{
ll pw=sum(v[i]^v[i-1]);
p=rd(l,l+pw);
if (p!=all)
{
for (ll i=l;i<=r;i++)
{
ll ne=rd(i,i);
rd(i,i);
if (ne==p+1)
{
all--;
go(l,i-1),go(i+1,r);
return;
}
}
}
}
}
void sol()
{
cin>>n;
all=n;
go(1,n);
}
int main(){
//ios::sync_with_stdio(0); cin.tie(0);
int tt=1;
//cin>>tt;
while (tt--)
sol();
return 0;
}
/*
3
2
1 1
2 2
4
0 1
1 0
3 1
4 0
5
0 1
1 0
1 2
2 2
4 2
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3544kb
input:
3 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 3
output:
1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 1 2 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 2 3 2 2 2 2
result:
ok OK, 18 queries
Test #2:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
1 0 1
output:
1 1 1 1 1 2
result:
ok OK, 1 queries
Test #3:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
2 1 2
output:
1 1 1 1 1 2
result:
ok OK, 1 queries
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3724kb
input:
2 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0
output:
1 1 1 1 1 1 1 1 2 2 2 2 1 2 1 1 1 1 2 2 2 2 1 2 1 1 1 1 2 2 2 2 1 2 1 1 1 1 2 2 2 2
result:
wrong answer format Unexpected end of file - int32 expected