Submission #633276

# Submission time Handle Problem Language Result Execution time Memory
633276 2022-08-22T03:56:46 Z Spade1 Aliens (IOI07_aliens) C++14
100 / 100
3 ms 240 KB
#include<bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

const int N = 1e5 + 10;
int n, x, y;

bool examine(ll x, ll y) {
    if (x < 1 || y < 1 || x > n || y > n) return 0;
    cout << "examine " << x << " " << y << endl;
    string s; cin >> s;
    return (s=="true");
}

ll find(int i, int j) {
    ll jump = 1;
    while (examine(x+i*jump, y+j*jump)) jump *= 2;
    ll l = jump/2, r = jump;
    while (l < r) {
        ll mid = (l+r+1)/2;
        if (examine(x+i*mid, y+j*mid)) l = mid;
        else r = mid-1;
    }
    return l;
}

void solve() {
    cin >> n >> x >> y;
    ll lb = x-find(-1, 0), rb = x+find(1, 0), ub = y+find(0, 1), db = y-find(0, -1);
    ll cx = (lb+rb)/2, cy = (ub+db)/2;
    ll M = (rb-lb+1);

    ll x = cx, y = cy;
    while (examine(x, y)) x += 2*M;
    ll E = x - 2*M;
    x = cx, y = cy;
    while (examine(x, y)) x -= 2*M;
    ll W = x + 2*M;
    x = cx, y = cy;
    while (examine(x, y)) y += 2*M;
    ll N = y - 2*M;
    x = cx, y = cy;
    while (examine(x, y)) y -= 2*M;
    ll S = y + 2*M;
    cout << "solution " << (E+W)/2 << " " << (N+S)/2 << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 240 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct