답안 #989309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
989309 2024-05-28T00:42:16 Z PedroBigMan Aliens (IOI07_aliens) C++14
80 / 100
2 ms 344 KB
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro "<<i<<endl
#define INF 1000000000000000000LL
#define EPS ((ld)0.00000000001)
#define pi ((ld)3.141592653589793)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

ll N, X, Y;

ll ask(ll x, ll y)
{
    if(x<0LL || x>=N || y<0LL || y>=N) {return 0LL;}
    cout<<"examine "<<x+1LL<<" "<<y+1LL<<endl;
    string ans; cin>>ans;
    if(ans=="true") {return 1LL;} else {return 0LL;}
}

void ans(ll x, ll y)
{
    cout<<"solution "<<x+1LL<<" "<<y+1LL<<endl;
}

ll max_direction(ll dx, ll dy)
{
    ll lo=0, hi=N-1, mid, thisans;
    while(lo<hi)
    {
        mid=(lo+hi+1LL)/2LL;
        thisans = ask(X+dx*mid,Y+dy*mid);
        if(thisans==0) {hi=mid-1LL; continue;}
        thisans = ask(X+dx*(mid/2LL),Y+dy*(mid/2LL));
        if(thisans==0) {hi=mid/2LL -1LL;} else {lo=mid;}
    }  
    return lo; 
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	cout.precision(20);
	cin>>N>>X>>Y; X--; Y--;
    ll up = max_direction(-1LL,0LL); ll down = max_direction(1LL,0LL); ll left = max_direction(0LL,-1LL); ll right = max_direction(0LL,1LL);
    ll M = left+right+1LL;
    X+=(down-up)/2LL; Y+=(right-left)/2LL;
    ll numdown, numright, numleft, numup;
    REP(i,1,4) {if(ask(X+2LL*M*i,Y)==0) {numdown=i-1; break;}}
    REP(i,1,4) {if(ask(X-2LL*M*i,Y)==0) {numup=i-1; break;}}
    REP(i,1,4) {if(ask(X,Y+2LL*M*i)==0) {numright=i-1; break;}}
    REP(i,1,4) {if(ask(X,Y-2LL*M*i)==0) {numleft=i-1; break;}}
    if((numdown+numup)==2LL) {X+=(2LL*M*(numdown-1LL));} else {X+=(M*(2LL*numdown-1LL));}
    if((numleft+numright)==2LL) {Y+=(2LL*M*(numright-1LL));} else {Y+=(M*(2LL*numright-1LL));}
    ans(X,Y);
    return 0;
}

Compilation message

aliens.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization ("O3")
      | 
aliens.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("unroll-loops")
      | 
aliens.cpp: In function 'int main()':
aliens.cpp:88:16: warning: 'numleft' may be used uninitialized in this function [-Wmaybe-uninitialized]
   88 |     if((numleft+numright)==2LL) {Y+=(2LL*M*(numright-1LL));} else {Y+=(M*(2LL*numright-1LL));}
      |        ~~~~~~~~^~~~~~~~~~
aliens.cpp:88:78: warning: 'numright' may be used uninitialized in this function [-Wmaybe-uninitialized]
   88 |     if((numleft+numright)==2LL) {Y+=(2LL*M*(numright-1LL));} else {Y+=(M*(2LL*numright-1LL));}
      |                                                                           ~~~^~~~~~~~~
aliens.cpp:87:16: warning: 'numup' may be used uninitialized in this function [-Wmaybe-uninitialized]
   87 |     if((numdown+numup)==2LL) {X+=(2LL*M*(numdown-1LL));} else {X+=(M*(2LL*numdown-1LL));}
      |        ~~~~~~~~^~~~~~~
aliens.cpp:87:74: warning: 'numdown' may be used uninitialized in this function [-Wmaybe-uninitialized]
   87 |     if((numdown+numup)==2LL) {X+=(2LL*M*(numdown-1LL));} else {X+=(M*(2LL*numdown-1LL));}
      |                                                                       ~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 340 KB Incorrect
3 Halted 0 ms 0 KB -