# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080348 | lovrot | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1440;
int dwarf = 1, ans[N];
char c[10];
bool ask(int t) {
int h = t / 60, m = t % 60;
printf("at %d%d:%d%d check %d\n", h / 10, h % 10, m / 10, m % 10, dwarf);
fflush(stdout);
scanf(" %s ", c);
return c[1] == 's';
} // 1 - sleep, 0 - wake
int main() {
int n; scanf("%d", &n);
for(int &i = dwarf; i <= n; ++i) {
bool f = ask(0);
int lo = 0, hi = N / 2;
for(int mi = (lo + hi) / 2; hi - lo > 1; mi = (lo + hi) / 2) {
bool res = ask(mi);
if(res == f) {
lo = mi;
} else {
hi = mi;
}
}
ans[i] = !f ? lo + 1 : (lo + N / 2 + 1) % N;
}
printf("answer\n");
for(int i = 0; i < n; ++i) {
int h = ans[i] / 60, m = ans[i] % 60;
printf("%d%d:%d%d\n", h / 10, h % 10, m / 10, m % 10);
}
fflush(stdout);
return 0;
}