Submission #951108

#TimeUsernameProblemLanguageResultExecution timeMemory
951108koukirocksColors (BOI20_colors)C++17
22 / 100
1 ms600 KiB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
 
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=2e5+10,P=998244353;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;

int n;

int main() {
	speed;
	cin>>n;
	int cnt=0;
	if (n<=64) {
		int now=1;
		int x;
			cnt++;
		cout<<"? 1\n"<<flush;
		cin>>x;
		for (int i=1;i<n;i++) {
			now+=(i&1?1:-1)*(n-i);
			cnt++;
			cout<<"? "<<now<<"\n"<<flush;
			cin>>x;
			if (x==0) {
				cout<<"= "<<(n-i+1)<<"\n"<<flush;
				return 0;
			}
		}
		cout<<"= 1\n"<<flush;
	} else if (n<=125) {
		int now=n+1>>1;
		int sml;
		cout<<"? "<<now<<"\n"<<flush;
		cin>>sml;
		cout<<"? 1\n"<<flush;
		cin>>sml;
		if (sml) {
			n=(n+1>>1)-1;
			now=1;
			for (int i=1;i<n;i++) {
				now+=(i&1?1:-1)*(n-i);
				int x;
				cout<<"? "<<now<<"\n"<<flush;
				cin>>x;
				if (x==0) {
					cout<<"= "<<(n-i+1)<<"\n"<<flush;
					return 0;
				}
			}
			cout<<"= 1\n"<<flush;
		} else {
			n=(n+1>>1)-1;
			now=1;
			for (int i=1;i<n;i++) {
				now+=(i&1?1:-1)*(2*n-i+1);
				int x;
				cout<<"? "<<now<<"\n"<<flush;
				cin>>x;
				if (x==0) {
					cout<<"= "<<(2*n-i+2)<<"\n"<<flush;
					return 0;
				}
			}
			cout<<"= "<<n+1<<"\n"<<flush;
		}
	}
	return 0;
}

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:41:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |   int now=n+1>>1;
      |           ~^~
Colors.cpp:48:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |    n=(n+1>>1)-1;
      |       ~^~
Colors.cpp:62:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |    n=(n+1>>1)-1;
      |       ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...