# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
680564 | Cross_Ratio | Colors (BOI20_colors) | C++14 | 3 ms | 336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
int point(int k) {
if(k==1) return 1;
if(k==2) return 2;
if(k==3) return 2;
if(k==4) return 3;
if(k==5) return 4;
if(k==6) return 5;
if(k%2==0) {
int n = k / 2;
int p = point(n);
if(p < (n+1)/2) {
return p + n;
}
return p;
}
int n = k/2;
int p = point(n+1);
if(p < (n+2)/2) {
return p + n;
}
return p;
}
vector<bool> res;
vector<int> cnt;
void answer(int c) {
cout << "= " << c << endl;
}
bool query(int c) {
cout << "? " << c << endl;
bool k;
cin >> k;
return k;
}
signed main() {
int N;
cin >> N;
int i, j;
int p = point(N);
if(N==1) {
answer(1);
return 0;
}
query(p);
int d = (N+1)/2;
int rev = 0;
if(p+d<=N) {
rev = 1;
}
else rev = 0;
int ans = 0;
while(true) {
//cout << "Current N is " << N << '\n';
if(N==1) {
answer(ans+1);
return 0;
}
int d = N / 2 + ans;
if(rev) p += d;
else p -= d;
bool k = query(p);
rev = 1 - rev;
if(k) N = N / 2;
else {
ans += N / 2;
N = N - N / 2;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |