Submission #828249

# Submission time Handle Problem Language Result Execution time Memory
828249 2023-08-17T07:10:37 Z vjudge1 Aliens (IOI07_aliens) C++17
30 / 100
3 ms 208 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll N, X0, Y0, M;
ll x,y;
ll up, down, lef, righ;
string torf;
bool cek=true;
bool cevrypos(int fx, int fy) {
    ll tanx, tany;
    bool fourwi[5]={false};
    //tanya atasnya
    tany = fy+2*M+M/2;
    tanx = fx;
    if(tany>=1 && tany<=N && tanx>=1 && tanx<=N) {
        cout << "examine " << tanx << " " << tany << endl;
        cin >> torf;
        if(torf=="true") {
            fourwi[1] = true;
        }
    }
    if(fourwi[1]==false) return false;
    //tanya bawahnya
    tany = fy-2*M-M/2;
    tanx = fx;
    if(tany>=1 && tany<=N && tanx>=1 && tanx<=N) {
        cout << "examine " << tanx << " " << tany << endl;
        cin >> torf;
        if(torf=="true") {
            fourwi[2] = true;
        }
    }
    if(fourwi[2]==false) return false;
    //tanya kirinya
    tanx = fx-2*M-M/2;
    tany = fy;
    if(tanx>=1 && tanx<=N && tany>=1 && tany<=N) {
        cout << "examine " << tanx << " " << tany << endl;
        cin >> torf;
        if(torf=="true") {
            fourwi[3] = true;
        }
    }
    if(fourwi[3]==false) return false;
    //tanya kanannya
    tanx = fx+2*M+M/2;
    tany = fy;
    if(tanx>=1 && tanx<=N && tany>=1 && tany<=N) {
        cout << "examine " << tanx << " " << tany << endl;
        cin >> torf;
        if(torf=="true") {
            fourwi[4] = true;
        }
    }
    if(fourwi[4]==false) return false;

    return true;
}
int main() {
    cin >> N >> X0 >> Y0;
    up = Y0;
    down = Y0;
    righ = X0;
    lef = X0;
    x = X0;
    y = Y0;
    //cek batas atas
    while(cek==true) {
        y++;
        if(y<=N) {
            cout << "examine " << x << " " << y << endl;
            cin >> torf;
            if(torf=="true") {
                cek=true;
                up = y;
            } else {
                cek = false;
            }
        } else {
            break;
        }
    }
    cek = true;
    x = X0;
    y = Y0;
    //cek batas bawah
    while(cek==true) {
        y--;
        if(y>=1) {
            cout << "examine " << x << " " << y << endl;
            cin >> torf;
            if(torf=="true") {
                cek=true;
                down=y;
            } else {
                cek=false;
            }
        } else {
            break;
        }
    }
    cek=true;
    x = X0;
    y = Y0;
    //cek batas kanan
    while(cek==true) {
        x++;
        if(x<=N) {
            cout << "examine " << x << " " << y << endl;
            cin >> torf;
            if(torf=="true") {
                cek=true;
                righ = x;
            } else {
                cek=false;
            }
        } else {
            break;
        }
    }
    cek=true;
    x = X0;
    y = Y0;
    //cek batas kiri
    while(cek==true) {
        x--;
        if(x>=1) {
            cout << "examine " << x << " " << y << endl;
            cin >> torf;
            if(torf=="true") {
                cek=true;
                lef = x;
            } else {
                cek=false;
            }
        } else {
            break;
        }
    }
    M = abs(up-Y0)+abs(Y0-down)+1;
    ll finx, finy;
    bool midofmid;
    //seandainya di square 1
    finx = righ+M+(M/2-1);
    finy = down-M-(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 2
    finx = lef+(M/2);
    finy = down-M-(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 3
    finx = lef-M-(M/2+1);
    finy = down-M-(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 4
    finx = righ+(M/2+1);
    finy = down-(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya square 5
    finx = lef-(M/2+1);
    finy = down-(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 6
    finx = righ+M+(M/2+1);
    finy = up-M/2;
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 7
    finx = lef+M/2;
    finy = up-M/2;
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 8
    finx = lef-M-(M/2+1);
    finy = up-M/2;
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 9
    finx = righ+(M/2+1);
    finy = up+(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 10
    finx = lef-(M/2+1);
    finy = up+(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 11
    finx = righ+M+(M/2+1);
    finy = up+M+(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya di square 12
    finx = lef+(M/2);
    finy = up+M+(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    //seandainya square 13
    finx = lef-M-(M/2+1);
    finy = up+M+(M/2+1);
    midofmid = cevrypos(finx, finy);
    if(midofmid) {
        cout << "solution " << finx << " " << finy << endl;
        return 0;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 2 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 3 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -