QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#261317#7804. Intersegment ActivationGeospizaWA 1ms3880kbC++202.2kb2023-11-22 20:14:582023-11-22 20:15:04

Judging History

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

  • [2023-11-22 20:15:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3880kb
  • [2023-11-22 20:14:58]
  • 提交

answer

//#pragma GCC optimize(3,"Ofast","inline")
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int N = 1ll<<14;
ll n;
ll lowbit(ll x){
    return x&(-x);
}
ll query(int i,int j){
    cout<<i<<" "<<j<<endl;
    ll k;
    cin>>k;
    if(k==n){
        exit(0);
    }
    return k;
}
int	main(){
    ios::sync_with_stdio(0); cin.tie(0);
	int T=1;
	//cin>>T;
    map<int,int>mp;
    for(int i=0;i<14;i++){
        mp[1ll<<i]=i;
    }
    vector<ll>v(1,0);
    ll now=0,cnt=1,sta=0;
    while(cnt<N){
        if(sta==0){
            now^=1;
            v.push_back(now);
        }
        else{
            now^=2*(lowbit(now));
            v.push_back(now);
        }
        cnt++;sta^=1;
    }
	while(T--)
    {   
        ll k;
        cin>>n>>k;
        ll id=1,before=k;
        vector<int>vis(20);
        while(id<=n){
            if(query(id,id)<before){
                k=query(id,id);
                id++;
                continue;
            }
            if(vis[id]==1){
                id++;
                continue;
            }
            ll now=0;
            //cout<<id<<"-\n";
            for(int i=1;i<=(1ll<<(n-id+1));i++){
                if(k>before){
                    for(int j=id;j<=n;j++){
                        ll tmp = query(j,j);
                        if(tmp<k){
                            vis[j]=1;
                            tmp=query(j,j);
                        }
                        else if(tmp>k){
                            vis[j]=1;
                        }
                        k=tmp;
                    }
                }
                before=k;
                if(vis[id]==1){
                    break;
                }
                if(i==(1ll<<(n-id+1))){
                    break;
                }
                ll t=mp[v[i]^v[i-1]],f=0;
                for(int j=id;j<=t;j++){
                    if(vis[j]==1){
                        f=1;
                    }
                }
                if(f==1){
                    continue;
                }
                k=query(id,id+t);
            }
            id++;
        }
    }
}
/*


*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3820kb

input:

3
0
0
0
1
0
1
1
1
1
1
1
2
1
2
3

output:

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

result:

ok OK, 14 queries

Test #2:

score: 0
Accepted
time: 1ms
memory: 3880kb

input:

1
0
1

output:

1 1

result:

ok OK, 1 queries

Test #3:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

2
1
2

output:

1 1

result:

ok OK, 1 queries

Test #4:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

2
0
0
0
0
1
0
1
2

output:

1 1
1 1
1 2
1 1
1 1
1 1
2 2

result:

ok OK, 7 queries

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3628kb

input:

2
0
1
0
0
0
0
0

output:

1 1
1 1
1 2
1 1
2 2
2 2

result:

wrong answer format  Unexpected end of file - int32 expected