답안 #508772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
508772 2022-01-13T17:45:03 Z kevinxiehk Aliens (IOI07_aliens) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

int examine(int X, int Y) {
    cout << "examine " << X << ' ' << Y << endl;
    string s;
    cin >> s;
    return s == "true";
}
void solution(int x, int y) {
    cout << "solution " << x << ' ' << y << endl;
    return;
}

// TODO: global variables can be declared here
int n;
int yes(int x,int y){
    if(min(x,y)<=0||max(x,y)>n)return false;
    return examine(x,y);
}
pair<int,int>border(int dx,int dy,int x0,int y0){
    int step=1;
    int x=x0,y=y0;
    while(yes(x0+step*dx,y0+step*dy))step*=2;
    int lx=x0+step/2*dx,rx=x0+step*dx;
    int ly=y0+step/2*dy,ry=y0+step*dy;
    while(!(lx==rx&&ly==ry)){
        int mx=(lx+rx+dx)/2;
        int my=(ly+ry+dy)/2;
        if(yes(mx,my)){
            lx=mx;ly=my;
        }
        else{
            rx=mx-dx;ry=my-dy;
        }
    }
    return make_pair(lx,ly);
}
void findCenter(int N, int X0, int Y0) {
    // TODO: implementation
    n=N;
    int l=border(-1,0,X0,Y0).first;
    int r=border(1,0,X0,Y0).first;
    int d=border(0,-1,X0,Y0).second;
    int m=r-l+1;
    int mx=l+m/2;
    int my=d+m/2;
    m*=2;
    if(yes(mx+m,my)&&!yes(mx-m,my)){
        if(yes(mx+m*2,my))mx+=m;
        else mx+=m/2,my+=m/2;
    }
    else if(!yes(mx+m,my)&&yes(mx-m,my)){
        if(yes(mx-m*2,my))mx-=m;
        else mx-=m/2,my+=m/2;
    }
    if(!yes(mx,my-m))my+=m;
    if(!yes(mx,my+m))my-=m;
    solution(mx,my);
    return;
}

Compilation message

aliens.cpp: In function 'std::pair<long long int, long long int> border(long long int, long long int, long long int, long long int)':
aliens.cpp:24:9: warning: unused variable 'x' [-Wunused-variable]
   24 |     int x=x0,y=y0;
      |         ^
aliens.cpp:24:14: warning: unused variable 'y' [-Wunused-variable]
   24 |     int x=x0,y=y0;
      |              ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status