답안 #1051175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1051175 2024-08-09T22:13:54 Z Dennis_Jason Aliens (IOI07_aliens) C++14
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#define NMAX 200001
//#define int long long
#define pb push_back
#define eb emplace_back
#define MOD 1000000007
#define nl '\n'
#define INF  1000000007
#define LLONG_MAX 9223372036854775807
#define pii pair<int,int>
#define tpl tuple<int,int,int,int>
#pragma GCC optimize("O3")
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
 *
 *
    ----------------DEMONSTRATION-------------------
    Steps:
        1.Find Xright in given red cell
                                        =>M=xr-xl
        2.find Xleft in given red cell

        3.Find Ydown in given red cell => Yup=Ydown+m

        4.find cell_up,cell_right,cell_down,cell_left

        5.print Xc,Yc :)


    ---------------------END------------------------

 */
/*-------------Initialize------------*/
int n,x,y;
int Xr,Xl,Yu,Yd,Xc,Yc;
int Wl,Wr,Wd;
int m;
int Cl,Cr,Cd,Cu;



void find_Wl()
{
    int red=1;
    int cur=x;
    int k=0;

    while(red==1)
    {
        cur=x-pow(2,k);
        Wl=cur;
        k++;
        cout.flush()<<"examine "<<cur<<" "<<y<<nl;
        cout.flush();
        cin>>red;
        if(red==0)
            break;
    }
}
void find_Wr()
{
    int red=1;
    int cur=x+1;
    int k=0;

    while(red==1)
    {
        cur=x+pow(2,k);
        Wr=cur;
        k++;
        cout.flush()<<"examine "<<cur<<" "<<y<<nl;
        cout.flush();
        cin>>red;
        if(red==0)
            break;
    }
}
void find_Xl()
{
    int st=Wl;
    int dr=Wr;
    while(st<=dr)
    {
        int mid=(st+dr)/2;
        cout.flush()<<"examine "<<mid<<" "<<y<<nl;
        cout.flush();
        bool red;
        cin>>red;
        if(red)
        {
            dr=mid-1;
            Xl=mid;
        }
        else
            st=mid+1;

    }
}

void find_Xr()
{
    int st=Wl;
    int dr=Wr;
    while(st<=dr)
    {
        int mid=(st+dr)/2;
        cout.flush()<<"examine "<<mid<<" "<<y<<nl;
        cout.flush();
        bool red;
        cin>>red;
        if(red)
        {
            st=mid+1;
            Xr=mid;
        }
        else
            dr=mid-1;
    }
}

void calc_m()
{
    m=(Xr-Xl+1);
}
void find_Wd()
{
    int red=1;
    int cur=y;
    int k=0;
    while(red==1)
    {
        cur=y-pow(2,k);
        Wd=cur;
        k++;
        cout.flush()<<"examine "<<x<<" "<<cur<<nl;
        cout.flush();
        cin>>red;

        if(red==0)
            break;
    }
}
void find_Yd()
{
    int st=Wd;
    int dr=y;
    while(st<=dr)
    {
        int mid=(st+dr)/2;
        cout.flush()<<"examine "<<x<<" "<<mid<<nl;
        cout.flush();
        int red;
        cin>>red;
        if(red)
        {
            Yd=mid;
            dr=mid-1;
        }
        else
            st=mid+1;
    }
}
void calc_Yu()
{
    Yu=m+Yd-1;
}

void find_cellUp()
{
    int cur=Yu;
    Cu=cur;
    int red=1;
    int k=1;
    while(red==1)
    {
        cur=Yu+pow(m,k)+1;
        k++;
        cout.flush()<<"examine "<<x<<" "<<cur<<nl;
        cout.flush();
        cin>>red;
        if(red==0)
            break;
        Cu=cur;
    }
}
void find_cellDown()
{
    int cur=Yd;
    int k=1;
    int red=1;
    Cd=cur;
    while(red==1)
    {
        cur=Yd-pow(m,k)+1;
        k++;
        cout.flush()<<"examine "<<x<<" "<<cur<<nl;
        cout.flush();
        cin>>red;
        if(red==0)
            break;
        Cd=cur;
    }
}
void find_cellLeft()
{
    int cur=Xl;
    int k=1;
    int red=1;
    Cl=cur;
    while(red==1)
    {
        cur=Xl-pow(m,k)+1;
        k++;
        cout.flush()<<"examine "<<cur<<" "<<y<<nl;
        cout.flush();
        cin>>red;
        if(red==0)
            break;
        Cl=cur;
    }
}
void find_cellRight()
{
    int cur=Xr;
    int k=1;
    int red=1;
    Cr=cur;
    while(red==1)
    {
        cur=Xr+pow(m,k)+1;
        k++;
        cout.flush()<<"examine "<<cur<<" "<<y<<nl;
        cout.flush();
        cin>>red;
        if(red==0)
            break;
        Cr=cur;
    }
}
void find_mid()
{
    if(Cu!=Yu)
        Cu+=(m-1);
    if(Cd!=Yd)
        Cd-=(m-1);
    if(Cl!=Xl)
        Cl-=(m-1);
    if(Cr!=Xr)
        Cr+=(m-1);

   int red;
   //check
        cout.flush()<<"examine "<<Cl-3<<" "<<Cu+3<<nl;
        cout.flush();
        cin>>red;
        if(red)
            Cu=Cu+3,Cl=Cl-3;
//   //check right
//        cout.flush()<<"examine "<<Cr+3<<" "<<Cu+3<<nl;
//        cout.flush();
//        cin>>red;
//        if(red)
//            Cr+=3,Cu+=3

    Xc=(Cl+Cr)/2;
    Yc=(Cu+Cd)/2;

}
void print_solution()
{
    cout.flush()<<"solution "<<Xc<<" "<<Yc<<nl;
    cout.flush();
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>x>>y;
    find_Wl();
    find_Wr();
    find_Xl();
    find_Xr();
    calc_m();
    find_Wd();
    find_Yd();
    calc_Yu();
    find_cellDown();
    find_cellLeft();
    find_cellRight();
    find_cellUp();
    find_mid();
    print_solution();

    return 0;
}

Compilation message

aliens.cpp:9: warning: "LLONG_MAX" redefined
    9 | #define LLONG_MAX 9223372036854775807
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
                 from /usr/include/c++/10/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
                 from aliens.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX __LONG_LONG_MAX__
      |
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -