Submission #525654

#TimeUsernameProblemLanguageResultExecution timeMemory
525654prvocisloAliens (IOI07_aliens)C++17
0 / 100
37 ms65540 KiB
#include <algorithm> #include <iostream> #include <string> #include <random> #include <chrono> #include <vector> #include <cmath> #include <set> #include <map> #include <iomanip> #include <queue> #include <bitset> #include <cmath> #include <cassert> typedef long long ll; typedef long double ld; using namespace std; const int logn = 31; int n, xo, yo; vector<vector<int> > h; bool query(int i, int num) { int x, y; if (num == 0) x = i, y = yo; if (num == 1) x = xo, y = i; if (x < 1 || y < 1 || x > n || y > n) return false; cout << "examine " << x << " " << y << endl; //return h[x][y]; string s; cin >> s; return s == "true"; } int find_last(int l, int r, int good, int num) // najdeme posledne policko, ktore ma farbu l { while (l < r) { int m = (l + r + 1) / 2; if (query(m, num) == good) l = m; else r = m - 1; } return l; } int find_one(int i0, int num) { int lw = i0, rw = i0; for (int b = 0; b < logn; b++) { int i = i0 - min(1 << b, i0); if (lw == i0 && !query(i, num)) lw = i; i = i0 + min(1 << b, n + 1 - i0); if (rw == i0 && !query(i, num)) rw = i; } if (lw == i0) lw = 0; if (rw == i0) rw = n + 1; int lb = find_last(lw, i0, 0, num) + 1; int rb = find_last(i0, rw, 1, num); int k = rb - lb + 1; int first = lb; while (query(first - 2 * k, num)) first -= 2 * k; return first + (5 * k) / 2; } int main() { cin >> n >> xo >> yo; h.assign(n + 1, vector<int>(n + 1)); //for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> h[i + 1][j + 1]; int xc = find_one(xo, 0); int yc = find_one(yo, 1); cout << "solution " << xc << " " << yc << endl; return 0; }

Compilation message (stderr)

aliens.cpp: In function 'bool query(int, int)':
aliens.cpp:24:9: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |  int x, y;
      |         ^
aliens.cpp:24:6: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |  int 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...