답안 #431337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431337 2021-06-17T11:04:33 Z juggernaut Aliens (IOI07_aliens) C++17
20 / 100
4 ms 256 KB
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
typedef long long ll;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef IOI2021SG
    #define printl(args...)printf(args)
#else
    #define printl(args...)((void)0)
#endif
int n;
bool check(int x,int y){
    if(!(x&&y&&x<=n&&y<=n))return false;
    printf("examine %d %d\n",x,y);
    fflush(stdout);
    string s;
    cin>>s;
    return s=="true";
}
int main(){
    int x,y;
    cin>>n>>x>>y;
    int l,r;
    l=0,r=x-1;
    while(l<r){
        int mid=(l+r+1)>>1;
        if(check(x-mid,y))l=mid;
        else{
            if(check(x-mid,y-mid))l=mid;
            else if(check(x-mid,y+mid))l=mid;
            else r=mid-1;
        }
    }
    int x1=x-l;
    l=0,r=n-x;
    while(l<r){
        int mid=(l+r+1)>>1;
        if(check(x+mid,y))l=mid;
        else{
            if(check(x+mid,y-mid))l=mid;
            else if(check(x+mid,y+mid))l=mid;
            else r=mid-1;
        }
    }
    int x2=x+l;
    l=0,r=y-1;
    while(l<r){
        int mid=(l+r+1)>>1;
        if(check(x,y-mid))l=mid;
        else{
            if(check(x-mid,y-mid))l=mid;
            else if(check(x+mid,y-mid))l=mid;
            else r=mid-1;
        }
    }
    int y1=y-l;
    int y2=y1+(x2-x1);
    printf("solution %d %d\n",(x1+x2)/2,(y1+y2)/2);
}

Compilation message

aliens.cpp: In function 'void usaco(std::string)':
aliens.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 2 ms 200 KB Incorrect
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 240 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 200 KB Output is correct
2 Incorrect 4 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 200 KB Output is correct
2 Incorrect 2 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -