제출 #302877

#제출 시각아이디문제언어결과실행 시간메모리
302877AkashiAliens (IOI07_aliens)C++14
100 / 100
3 ms256 KiB
#include <bits/stdc++.h> using namespace std; bool debug = false; int n, x, y; char s[15]; bool f[105][105]; bool ask(int x, int y) { if (x <= 0 || y <= 0 || x > n || y > n) return false; bool ok = false; cout << "examine " << x << " " << y; cout << endl; if (!debug) { scanf("%s", s); if (s[0] == 't') ok = true; return ok; } else return f[x][y]; } void found(int x, int y) { cout << "solution " << x << " " << y; cout << endl; } 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 && y > 0) { bool ok = ask(x - m, y - m); if (ok) x -= m, y -= m; else break ; } while (x > 0) { bool ok = ask(x - 2 * m, y); if (ok) x -= 2 * m; else break ; } while (y > 0) { bool ok = ask(x, y - 2 * m); if (ok) y -= 2 * 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; } } void init() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= 5 ; ++i) { for (int j = 1; j <= 5 ; ++j) { if ((i + j) % 2 == 0) { for (int x = 1 + (i - 1) * m; x <= i * m ; ++x) for (int y = 1 + (j - 1) * m ; y <= j * m ; ++y) f[x][y] = 1; } } } for (int i = 1; i <= n ; ++i) { for (int j = 1; j <= n ; ++j) cerr << f[i][j]; cerr << endl; } } int main() { if (debug) init(); cin >> 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; }

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'bool ask(int, int)':
aliens.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%s", s);
      |         ~~~~~^~~~~~~~~
aliens.cpp: In function 'void init()':
aliens.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   80 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
#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...