# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1080348 |
2024-08-29T09:00:57 Z |
lovrot |
Cave (IOI13_cave) |
C++17 |
|
0 ms |
0 KB |
#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;
}
Compilation message
cave.cpp: In function 'bool ask(int)':
cave.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf(" %s ", c);
| ~~~~~^~~~~~~~~~~
cave.cpp: In function 'int main()':
cave.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | int n; scanf("%d", &n);
| ~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/cczQEoff.o: in function `main':
cave.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqZJjqh.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqZJjqh.o: in function `main':
grader.c:(.text.startup+0x10): undefined reference to `exploreCave'
collect2: error: ld returned 1 exit status