이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 1e16;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
int n,x,l,r,val;
int ask(int what) {
cout << "? " << what << endl;
int tmp; cin >> tmp;
return tmp;
}
void answer(int what) {
cout << "= " << what << endl;
exit(0);
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
if(n == 1) answer(1);
if(n == 2) {
ask(1);
val = ask(2);
answer(1+!val);
}
val = ask(1);
val = ask(n);
if(!val) answer(n);
val = ask((n+1)/2);
if(val) {
l = (n+1)/2+2, r = n-2;
int x = n-1;
for(int len = (n-(n+1)/2)-1;len >= 1;len--) {
val = ask(x);
if(!val) answer(len+1);
if(x-1 == r) x = l++;
else x = r--;
}
answer(1);
return 0;
}
else {
if(n == 3) answer(2);
val = ask(n-1);
//if(!val) answer(n-((n+1)/2));
l = 3, r = n-2;
int x = 2;
for(int len = n-3;len > n-1-((n+1)/2);len--) {
val = ask(x);
if(!val) answer(len+1);
if(x-1 == r) x = l++;
else x = r--;
}
answer(n-((n+1)/2));
return 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
Colors.cpp:6: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
6 | #pragma gcc optimize("O3")
|
Colors.cpp:7: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
7 | #pragma gcc optimize("Ofast")
|
Colors.cpp:8: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
8 | #pragma gcc optimize("unroll-loops")
|
# | 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... |