Submission #226094

#TimeUsernameProblemLanguageResultExecution timeMemory
226094farmerboySnake (CEOI08_snake)C++14
35 / 100
1 ms504 KiB
/* Author: Nguyen Tan Bao Status: Idea: */ #include <bits/stdc++.h> #include "snakelib.h" #define FI first #define SE second #define EPS 1e-9 #define ALL(a) a.begin(),a.end() #define SZ(a) int((a).size()) #define MS(s, n) memset(s, n, sizeof(s)) #define FOR(i,a,b) for (int i = (a); i <= (b); i++) #define FORE(i,a,b) for (int i = (a); i >= (b); i--) #define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) //__builtin_ffs(x) return 1 + index of least significant 1-bit of x //__builtin_clz(x) return number of leading zeros of x //__builtin_ctz(x) return number of trailing zeros of x using namespace std; using ll = long long; using ld = double; typedef pair<int, int> II; typedef pair<II, int> III; typedef complex<ld> cd; typedef vector<cd> vcd; const ll MODBASE = 1000000007LL; const int MAXN = 12122; const int MAXM = 1000; const int MAXK = 16; const int MAXQ = 200010; int main() { ios::sync_with_stdio(0); cin.tie(nullptr); int k = get_speed(); int leftLow = 0, leftHigh = MAXN, rightLow = 0, rightHigh = MAXN; char a1, a2; FOR(i,1,13) { rightLow = min(rightLow + k, MAXN-1); rightHigh = min(rightHigh + k, MAXN); int leftMid = (leftLow + leftHigh - 1) / 2; int rightMid = (rightLow + rightHigh) / 2; if (i == 1) { leftMid = (leftLow + leftLow + leftHigh) / 3; rightMid = (rightLow + rightHigh + rightHigh) / 3; } ask_snake(leftMid, rightMid, &a1, &a2); if (a1 == 'b') { leftLow = min(leftMid + 1, MAXN-1); rightLow = max(rightLow, leftLow); } else if (a1 == 's') { leftHigh = leftMid + 1; rightLow = max(rightLow, leftMid); } else { leftHigh = leftMid; rightHigh = min(rightHigh, leftHigh); } if (a2 == 'b') { rightLow = min(rightMid + 1, MAXN-1); leftLow = max(leftLow, rightLow); } else if (a2 == 's') { rightLow = rightMid; leftHigh = min(leftHigh, rightMid + 1); } else { rightHigh = rightMid; leftHigh = min(leftHigh, rightHigh); } } int maxRes = rightHigh - leftLow + 1, minRes = rightLow - leftHigh + 1; // cout << leftLow << ' ' << leftHigh << ' ' << rightLow << ' ' << rightHigh << endl; int guess = (maxRes + minRes) / 2; tell_length(guess); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...