Submission #1339035

#TimeUsernameProblemLanguageResultExecution timeMemory
1339035po_rag526Aliens (IOI07_aliens)C++20
30 / 100
1 ms420 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 201;
#define vi vector<int>
#define vvi vector<vector<int>>
#define mk(x,y) make_pair(x,y)
int sizee;
pair<int , int> findcenter(int x0 , int y0 , int n){
    string ask;
    int countx1 = 0 , countx2 = 0;
    int county1 = 0 , county2 = 0;
    int finalx , finaly;
    for(int i = 1; i <= n;i++){
        if(x0 + i <= n){
            cout << "examine " << x0 + i << " " << y0 << endl;
            cin >> ask;
            if(ask == "false"){
                break;
            }
            countx1++;
        }
        else{
            break;
        }
    }
    for(int i = 1; i <= n;i++){
        if(x0 - i >= 1){
            cout << "examine " << x0 - i << " " << y0 << endl;
            cin >> ask;
            if(ask == "false"){
                break;
            }
            countx2++;
        }
        else{
            break;
        }
    }
    for(int i = 1; i <= n;i++){
        if(y0 + i <= n){
            cout << "examine " << x0 << " " << y0 + i << endl;
            cin >> ask;
            if(ask == "false"){
                break;
            }
            county1++;
        }
        else{
            break;
        }
    }
    for(int i = 1; i <= n;i++){
        if(y0 - i >= 1){
            cout << "examine " << x0 << " " << y0 - i << endl;
            cin >> ask;
            if(ask == "false"){
                break;
            }
            county2++;
        }
        else{
            break;
        }
    }
    sizee = countx1 + countx2 + 1;
    // cout << countx1 << ' ' << countx2 << ' ' << county1 << ' ' << county2 << endl;
    if(countx1 >= countx2){
        finalx = x0 + ((countx1 - countx2) / 2);
    }
    else finalx = x0 - ((countx2 - countx1) / 2);
    if(county1 >= county2){
        finaly = y0 + ((county1 - county2) / 2);
    }
    else finaly = y0 - ((county2 - county1)/2);
    return mk(finalx ,finaly);
}
void solve(){
    int n ,x0 ,y0;
    string ask;
    cin >> n >> x0 >> y0;
    pair<int , int> center = findcenter(x0 , y0 , n);
    int cx = center.first , cy = center.second;
    int countx1 = 0, countx2 = 0 ,county1= 0, county2=0;
    int count2x1 = 0, count2x2 = 0, count2y1 = 0, count2y2 = 0;
    int lastx , lasty;
    if(cx + 2*sizee  <= n){
        cout << "examine " << cx +2*sizee << ' '  <<cy << endl;
        cin >> ask;
        if(ask == "true"){
            countx1++;
        }
    }
    if(cx + 4 * sizee  <= n){
        cout << "examine " << cx +4*sizee  << ' '  <<cy << endl;
        cin >> ask;
        if(ask == "true"){
            countx2++;
        }
    }
    if(cx - 2*sizee  >= 1){
        cout << "examine " << cx -2*sizee  << ' '  <<cy << endl;
        cin >> ask;
        if(ask == "true"){
            count2x1++;
        }
    }
    if(cx - 4 * sizee  >= 1){
        cout << "examine " << cx -4*sizee << ' '  <<cy << endl;
        cin >> ask;
        if(ask == "true"){
            count2x2++;
        }
    }

    if(cy + 2*sizee <= n){
        cout << "examine " <<  cx << ' '  <<cy +2*sizee<< endl;
        cin >> ask;
        if(ask == "true"){
            county1++;
        }
    }
    if(cy + 4 * sizee  <= n){
        cout << "examine " << cx << ' '  <<cy +4*sizee  << endl;
        cin >> ask;
        if(ask == "true"){
            county2++;
        }
    }
    if(cy - 2*sizee  >= 1){
        cout << "examine " << cx << ' '  << cy -2*sizee << endl;
        cin >> ask;
        if(ask == "true"){
            count2y1++;
        }
    }
    if(cy - 4 * sizee  >= 1){
        cout << "examine " << cx << ' '  <<cy -4*sizee  << endl;
        cin >> ask;
        if(ask == "true"){
            count2y2++;
        }
    }
    if(countx1 + countx2 + count2x2 + count2x1 == 1){
        if(countx2 > countx1){
            lastx = cx - sizee;
        }
        else{
            lastx = cx + sizee;
        }
        if(county1 > county2){
            lasty = cy + sizee;
        }
        else lasty = cy - 2*sizee;
    }
    else{
        if(countx1 == 0){
            lastx = cx - 2*sizee;
        }
        else if(countx1 == 1 && countx2 ==0){
            lastx = cx;
        }
        else{
            lastx = cx + 2*sizee;
        }
        if(county1 == 0){
            lasty = cy - 2*sizee;
        }
        else if(county1 == 1 && county2 == 0){
            lasty = cy;
        }
        else lasty = cy + 2*sizee;
    }
    cout << "solution " << lastx << ' ' << lasty;
}
signed main(){
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}   
#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...