Submission #431433

# Submission time Handle Problem Language Result Execution time Memory
431433 2021-06-17T11:53:08 Z juggernaut Aliens (IOI07_aliens) C++17
100 / 100
5 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
ll n;
bool check(ll x,ll y){
    if(!(x>0&&y>0&&x<=n&&y<=n))return false;
    printf("examine %lld %lld\n",x,y);
    fflush(stdout);
    string s;
    cin>>s;
    return s=="true";
}
int main(){
    ll x,y;
    cin>>n>>x>>y;
    ll pivot=1;
    ll l,r;
    while(check(x-pivot,y))pivot<<=1;
    l=x-pivot+1;
    r=x;
    while(l<r){
        ll mid=(l+r)>>1;
        if(check(mid,y))r=mid;
        else l=mid+1;
    }
    ll x1=l;
    pivot=1;
    while(check(x+pivot,y))pivot<<=1;
    l=x;
    r=x+pivot-1;
    while(l<r){
        ll mid=(l+r+1)>>1;
        if(check(mid,y))l=mid;
        else r=mid-1;
    }
    ll x2=l;
    ll m=x2-x1+1;

    l=y-m+1;
    r=y;
    while(l<r){
        ll mid=(l+r)>>1;
        if(check(x,mid))r=mid;
        else l=mid+1;
    }

    x=x1;
    y=l;
    while(check(x-2*m,y))x-=2*m;
    if(check(x-m,y-m))x-=m,y-=m;

    while(check(x,y-2*m))y-=2*m;
    printf("solution %lld %lld\n",x+2*m+(m/2),y+2*m+(m/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);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 2 ms 220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 3 ms 200 KB Output is correct