# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
951627 | koukirocks | Colors (BOI20_colors) | C++17 | 2 ms | 756 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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,r=n-1;
while (l<=r) {
ll mid=(l+r)/2;
cross.push_back(mid);
l=mid+1;
}
reverse(all(cross));
ll now=1;
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-1;
ll cnt=(now<=n/2);
query(now);
ll ans=n;
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 {
ans=mid;
r=mid-1;
}
}
cout<<"= "<<ans<<"\n"<<flush;
return 0;
}
컴파일 시 표준 에러 (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... |