QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#261047#7804. Intersegment ActivationGeospiza#WA 1ms3580kbC++201.9kb2023-11-22 17:36:572023-11-22 17:36:57

Judging History

你现在查看的是最新测评结果

  • [2023-11-22 17:36:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3580kb
  • [2023-11-22 17:36:57]
  • 提交

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 flag=0;

ll rd(ll l,ll r)
{
    if (flag)
        return n;
    cout<<l<<" "<<r<<endl;
    ll ans;
    cin>>ans;
    if (ans==n)
        flag=1;
    return ans;
}

ll all=0;


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=0;
    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: 0
Wrong Answer
time: 1ms
memory: 3580kb

input:

3
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
1
0
1
1
1
0
1

output:

1 1
1 1
1 2
1 2
1 1
1 1
2 2
2 2
2 2
2 2
3 3
3 3
2 3
2 2
2 2
3 3
3 3
2 3
2 3
2 2
2 2
3 3
3 3

result:

wrong answer format  Unexpected end of file - int32 expected