제출 #867368

#제출 시각아이디문제언어결과실행 시간메모리
867368Ning07Aliens (IOI07_aliens)C++17
0 / 100
2 ms500 KiB
#pragma warning(disable : 4996) #include<bits/stdc++.h> using namespace std; using ll = long long; #define L(i,j,k) for(int i=(j);i<=(k);i++) #define R(i,j,k) for(int i=(j);i>=(k);i--) int n, x_given, y_given, sz; int ansx, ansy; void read() { cin >> n >> x_given >> y_given; return; } bool ask(int x, int y) { cout << "examine " << x << ' ' << y << endl; fflush(stdout); string s; cin >> s; return s == "true"; } bool is_grass(int x, int y) { if (x <= 0 || x >= n + 1 || y <= 0 || y >= n + 1) return false; return ask(x, y); } pair<int, int> last_black(ll x, ll y, int dx, int dy) { int l = 0, r = 60, meow = -1; while (l <= r) { int mid = (l + r) >> 1; if (is_grass(x + dx * (1LL << mid), y + dy * (1LL << mid))) l = mid + 1, meow = mid; else r = mid - 1; } if (meow==-1) return make_pair(x, y); return last_black(x + dx * (1 << meow), y + dy * (1 << meow), dx, dy); } int count_block(int x, int y, int dx, int dy) { int t = 1; while (is_grass(x + dx * (2*sz) * t, y + dy * (2*sz) * t)) t++; return max(0, t - 1); } void is_centre(int x, int y) { if (x <= 0 || x >= n + 1 || y <= 0 || y >= n + 1) return; bool ok = true; ok &= count_block(x, y, 1, 0) == 1; ok &= count_block(x, y, -1, 0) == 1; ok &= count_block(x, y, 0, 1) == 1; ok &= count_block(x, y, 0, -1) == 1; if (ok) { ansx = x; ansy = y; //cout << "Yes this is the centre\n"; } } void find_centre() { pair<int, int> a = last_black(x_given, y_given, 0, 1); pair<int, int> b = last_black(x_given, y_given, 0, -1); pair<int, int> c = last_black(x_given, y_given, 1, 0); pair<int, int> d = last_black(x_given, y_given, -1, 0); // cout << a.first << ' ' << a.second << '\n'; // cout << b.first << ' ' << b.second << '\n'; //cout << c.first << ' ' << c.second << '\n'; //cout << d.first << ' ' << d.second << '\n'; int difx = max({ a.first,b.first,c.first,d.first }) - min({ a.first,b.first,c.first,d.first }); int dify = max({ a.second,b.second,c.second,d.second }) - min({ a.second,b.second,c.second,d.second }); sz = difx + 1; //cout << "size , sx , sy: "; int midx = min({ a.first,b.first,c.first,d.first }) + difx / 2; int midy = min({ a.second,b.second,c.second,d.second }) + dify / 2; //cout << sz << ' ' << midx << ' ' << midy << '\n'; for (int i = -4; i <= 4; i++) { for (int j = -4; j <= 4; j++) { //cout << "checking if " << midx + i * sz << ' ' << midy + j * sz << " is a centre"; //cout << '\n'; is_centre(midx + i * sz, midy + j * sz); } } cout << "solution " << ansx << ' ' << ansy << '\n'; fflush(stdout); } int main() { read(); /*R(i, n, 1) L(j, 1, n) { char p; cin >> p; if (p == '1') can[j][i] = 1; else can[j][i] = 0; } cout << can[5][3] << '\n'; */ find_centre(); }

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

aliens.cpp:1: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    1 | #pragma warning(disable : 4996)
      |
#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...