답안 #951618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951618 2024-03-22T07:40:38 Z koukirocks Colors (BOI20_colors) C++17
0 / 100
1 ms 452 KB
#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=3e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;

ll n;

ll begin() {
	vector<ll> cross;
	ll l=1;
	while (l<n) {
		ll mid=(l+n)/2;
		cross.push_back(mid);
		l=mid+1;
	}
	reverse(all(cross));
	ll now=n;
	for (int i=0;i<cross.size();i++) {
		now+=((i&1)?1:-1)*cross[i];
	}
	return now;
}

int query(ll q) {
	cout<<"? "<<q<<"\n"<<flush;
	int x;
	cin>>x;
	return x;
}

int main() {
	speed;
	cin>>n;
	ll now=begin();
	ll l=1,r=n;
	ll cnt=(now<=n/2);
	query(now);
	while (l<r) {
		ll mid=(l+r)>>1;
		now+=((cnt&1)?1:-1)*mid;
		cnt^=1;
		int x=query(now);
		if (x==0) l=mid+1;
		else r=mid;
	}
	cout<<"= "<<l<<"\n"<<flush;
	return 0;
}

Compilation message

Colors.cpp: In function 'll begin()':
Colors.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int i=0;i<cross.size();i++) {
      |               ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -