Submission #233870

#TimeUsernameProblemLanguageResultExecution timeMemory
233870T0p_Aliens (IOI07_aliens)C++14
40 / 100
7 ms384 KiB
#include<bits/stdc++.h> using namespace std; bool examine(long long a, long long b) { printf("examine %lld %lld\n",a,b); fflush(stdout); char str[7]; scanf(" %s",str); return (str[0] == 't') ? true : false; } void solution(long long a, long long b) { printf("solution %lld %lld\n",a,b); fflush(stdout); } int main() { long long n, x, y, l, r, L, R, T, B, sz; scanf(" %lld %lld %lld",&n,&x,&y); //right l = x, r = n; while(l != r) { long long mid = (l+r+1)>>1ll; if(!examine(mid, y)) r = mid-1; else if(!examine((l+mid)>>1ll, y)) r = mid-1; else if(!examine((l+((l+mid)>>1ll))>>1ll, y)) r = mid-1; else l = mid; } R = l; //left l = 1, r = x; while(l != r) { long long mid = (l+r)>>1ll; if(!examine(mid, y)) l = mid+1; else if(!examine((mid+r)>>1ll, y)) l = mid+1; else if(!examine((((mid+r)>>1ll)+r)>>1ll, y)) l = mid+1; else r = mid; } L = l; //top l = y, r = n; while(l != r) { long long mid = (l+r+1)>>1ll; if(!examine(x, mid)) r = mid-1; else if(!examine(x, (l+mid)>>1ll)) r = mid-1; else if(!examine(x, (l+((l+mid)>>1ll))>>1ll)) r = mid-1; else l = mid; } T = l; sz = R-L+1; B = T-sz+1; long long mx = (L+R)>>1ll, my = (B+T)>>1ll; int tl = 0, tr = 0, bl = 0, br = 0; for(int i=1 ; i<=4 ; i++) { if(mx - i*sz >= 1 && my + i*sz <= n && examine(mx-i*sz, my+i*sz)) tl++; if(mx + i*sz <= n && my + i*sz <= n && examine(mx+i*sz, my+i*sz)) tr++; if(mx - i*sz >= 1 && my - i*sz >= 1 && examine(mx-i*sz, my-i*sz)) bl++; if(mx + i*sz <= n && my - i*sz >= 1 && examine(mx+i*sz, my-i*sz)) br++; } if(tl == 0) { if(tr == 4) solution(mx+2*sz, my+2*sz); else if(bl == 4) solution(mx-2*sz, my-2*sz); else if(br == 4) solution(mx+2*sz, my-2*sz); else if(tr == 2) solution(mx+sz, my); else solution(mx, my-sz); } else if(tl == 1) { if(tr == 3) solution(mx+sz, my+sz); else if(bl == 3) solution(mx-sz, my-sz); else solution(mx+sz, my-sz); } else if(tl == 2) { if(bl + br == 0) solution(mx, my+sz); else if(bl + br == 2) solution(mx-sz, my); else solution(mx, my); } else if(tl == 3) solution(mx-sz, my+sz); else solution(mx-2*sz, my+2*sz); return 0; }

Compilation message (stderr)

aliens.cpp: In function 'bool examine(long long int, long long int)':
aliens.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %s",str);
  ~~~~~^~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %lld %lld %lld",&n,&x,&y);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...