Submission #302871

#TimeUsernameProblemLanguageResultExecution timeMemory
302871AkashiAliens (IOI07_aliens)C++14
0 / 100
1 ms288 KiB
#include <bits/stdc++.h> using namespace std; int n, x, y; char s[15]; bool ask(int x, int y) { if (x <= 0 || y <= 0 || x > n || y > n) return false; bool ok = false; printf("examine %d %d\n", x, y); scanf("%s", s); if (s[0] == 't') ok = true; return ok; } void found(int x, int y) { printf("solution %d %d\n", x, y); } int find_dir(int x, int y, int sgn) { int wh = 0; for (int bit = 1; bit <= n ; bit = bit << 1) { bool ok = ask(x + bit * sgn, y); if (!ok) {wh = bit >> 1; break ;} } if (wh == 0) return 0; int ans = 0; for (int bit = wh; bit >= 1 ; bit = bit >> 1) { bool ok = ask(x + bit * sgn, y); if (ok) x += (bit * sgn), ans = ans + bit; } return ans; } void corect(int &x, int &y, int m) { while (x > 0) { bool ok = ask(x - m, y); if (ok) x -= m; else break ; } while (y > 0) { bool ok = ask(x, y - m); if (ok) y -= m; else break ; } for (int bit = (1 << 30); bit >= 1 ; bit = bit >> 1) { bool ok = ask(x - bit, y); if (ok) x -= bit; } for (int bit = (1 << 30); bit >= 1 ; bit = bit >> 1) { bool ok = ask(x, y - bit); if (ok) y -= bit; } } int main() { scanf("%d%d%d", &n, &x, &y); int up = find_dir(x, y, -1); int down = find_dir(x, y, 1); int m = up + down + 1; corect(x, y, m); found(x + 2 * m + m / 2, y + 2 * m + m / 2); return 0; }

Compilation message (stderr)

aliens.cpp: In function 'bool ask(int, int)':
aliens.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:65:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   65 |     scanf("%d%d%d", &n, &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...