답안 #970238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970238 2024-04-26T09:03:00 Z NoMercy Aliens (IOI07_aliens) C++14
100 / 100
2 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
 
    
int TIME = clock();
 
#define file \
            freopen("in.txt" , "r" , stdin); \
            freopen("out.txt" , "w" , stdout);
 
typedef long long ll;
 
void test_case () {
    ll n , x , y;
    cin >> n >> x >> y;
    auto ask = [&](ll fi , ll se) -> int {
        if (fi <= 0 || se <= 0 || fi > n || se > n) {
            return false;
        }
        cout << "examine " << fi << " " << se << endl;
        string as;
        cin >> as;
        return (as == "true");
    };
    ll l = 1, r = x , best[4] = {x , y , x , y};
    while (l <= r) {
        ll mid = (l + r) / 2LL;
        if (ask(mid , y) == true && ask((mid + x) / 2LL , y) == true && ask(((mid + (mid + x) / 2LL)) / 2LL , y) == true) {
            best[0] = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    l = 1 , r = y;
    while (l <= r) {
        ll mid = (l + r) / 2LL;
        if (ask(x , mid) == true && ask(x , (mid + y) / 2LL) == true && ask(x , ((mid + (mid + y) / 2LL)) / 2LL) == true) {
            best[1] = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    l = x , r = n;
    while (l <= r) {
        ll mid = (l + r) / 2LL;
        if (ask(mid , y) == true && ask((mid + x) / 2LL , y) == true && ask(((mid + (mid + x) / 2LL)) / 2LL , y) == true) {
            best[2] = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    l = y , r = n;
    while (l <= r) {
        ll mid = (l + r) / 2LL;
        if (ask(x , mid) == true && ask(x , (mid + y) / 2LL) == true && ask(x , ((mid + (mid + y) / 2LL)) / 2LL) == true) {
            best[3] = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    // cout << best[0] << " " << best[1] << " " << best[2] << " " << best[3] << endl;
    assert(best[2] - best[0] == best[3] - best[1]);
    x = (best[0] + best[2]) / 2LL;
    y = (best[1] + best[3]) / 2LL;
    ll m1 = best[2] - best[0] + 1;
    ll m2 = best[3] - best[1] + 1;
    ll m;
    if (m1 <= m2 && m1 % 2 != 0 && m1 > 1) {
        m = m1;
    } else {
        m = m2;
    }
    while (x - m > 0 && y - m > 0) {
        if (ask(x - m , y - m) == true) {
            x -= m;
            y -= m;
        } else {
            break;
        }
    }
    while (x - m - m > 0) {
        if (ask(x - m - m , y) == true) {
            x -= m * 2LL;
        } else {
            break;
        }
    }
    while (y - m - m > 0) {
        if (ask(x , y - m - m) == true) {
            y -= m * 2LL;
        } else {
            break;
        }
    }
    cout << "solution " << x + m + m << " " << y + m + m << endl;
}
 
int32_t main () {
 
        // file
    
 
    int t = 1;
    // cin >> t;
 
    while (t --) {
        test_case();
    }
 
    cerr << "\nTime elapsed: " << (clock() - TIME) * 1000.0 / CLOCKS_PER_SEC << " ms\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 436 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 436 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 436 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
3 Correct 2 ms 440 KB Output is correct