답안 #470571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
470571 2021-09-04T09:59:26 Z cp_is_hard Colors (BOI20_colors) C++14
0 / 100
1 ms 200 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

using namespace std;

#define INF 1000000000000000000
#define lld long double
#define int long long int
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else 
#define print(...)
#define vprint(...)
#endif
namespace solver {
	set<int> s;
	const int key = 999999999999999999;
	int cur, cnt, v, N;
	bool query(int p) {
//		assert(s.find(p) == s.end());
//		assert(p <= N);
		cout << "? " << p << endl;
		int x; cin >> x;
//		int x = abs(p - cur) >= key;
//		print(abs(p - cur), x);
		cur = p;
		cnt ++;
//		s.insert(p);
		return x;
	}
	void report(int x) {
		cout << "= " << x << endl;
	}
	void solve(int n) {
		int v = n - 1, yes = 0; 
		cur = 1, cnt = 0, N = n;
		rrep(i, 0, 62) if((v >> i) & 1) {
			if(yes) cur += (1ll << i);
			yes ^= 1;
		}
		yes = 0;
		query(cur);
		int ans = 0;
		rrep(i, 0, 62) if((ans | (1ll << i)) <= v){
			int id = (yes ? -1 : 1);
			if(!query(cur + id * (ans | (1ll << i)))) 
				ans |= (1ll << i);
			yes ^= 1;
		}
		report(ans + 1);
		print(cnt);
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n; cin >> n;
	solve(n);
	return 0;
}

Compilation message

Colors.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
Colors.cpp:21:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   21 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
Colors.cpp:21:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   21 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -