답안 #643862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643862 2022-09-23T06:48:05 Z KindaNameless Aliens (IOI07_aliens) C++14
10 / 100
2 ms 208 KB
#include<algorithm>
#include<assert.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<numeric>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<deque>
#include<cmath>
#include<map>
#include<set>
using namespace std;

#define ll long long
#define ld long double

ll N, cnt = 0;

bool ask(ll x, ll y){
    if(x <= 0 || y <= 0 || x > N || y > N)return 0;

    cnt++;
    assert(cnt <= 300);

    cout << "examine " << x << " " << y << "\n"; cout << flush;
    string s; cin >> s;
    return s[0] == 't';
}

ll check(ll x, ll y, ll dx, ll dy){
    ll p = 1;
    while(ask(x + p*dx, y + p*dy)){
        p *= 2LL;
    }

    ll l = p/2, r = p;
    while(r - l > 1){
        ll m = (l + r) / 2;
        if(ask(x + p*dx, y + p*dy)){
            l = m;
        }
        else r = m;
    }

    return l;
}

int main(){
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll x, y; cin >> N >> x >> y;

    ll L, R, D, U, a, b, c, d;
    L = x - check(x, y, -1, 0);
    R = x + check(x, y, 1, 0);
    D = y - check(x, y, 0, -1);
    U = y + check(x, y, 0, 1);

    ll M = R - L + 1;
    ll xc = (L + R)/2LL, yc = (D + U)/2LL;

    assert(M & 1LL);

    x = xc - 2LL*M; y = yc;
    while(ask(x, y))x -= 2LL*M;
    L = x + 2LL*M;

    x = xc + 2LL*M; y = yc;
    while(ask(x, y))x += 2LL*M;
    R = x - 2LL*M;

    x = xc; y = yc + 2LL*M;
    while(ask(x, y))y += 2LL*M;
    D = y - 2LL*M;

    x = xc; y = yc - 2LL*M;
    while(ask(x, y))y -= 2LL*M;
    U = y + 2LL*M;

    cout << "solution " << (L + R)/2LL << " " << (D + U)/2LL << "\n"; cout << flush;

    return 0;
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:57:20: warning: unused variable 'a' [-Wunused-variable]
   57 |     ll L, R, D, U, a, b, c, d;
      |                    ^
aliens.cpp:57:23: warning: unused variable 'b' [-Wunused-variable]
   57 |     ll L, R, D, U, a, b, c, d;
      |                       ^
aliens.cpp:57:26: warning: unused variable 'c' [-Wunused-variable]
   57 |     ll L, R, D, U, a, b, c, d;
      |                          ^
aliens.cpp:57:29: warning: unused variable 'd' [-Wunused-variable]
   57 |     ll L, R, D, U, a, b, c, d;
      |                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Incorrect 2 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -