Submission #827757

#TimeUsernameProblemLanguageResultExecution timeMemory
827757nninAliens (IOI07_aliens)C++14
100 / 100
2 ms296 KiB
#include<bits/stdc++.h> #define int long long #define pii pair<int,int> #define f first #define s second using namespace std; int n, x, y, m; bool interact(int xx, int yy) { if(xx==x && yy==y) return 1; printf("examine %lld %lld\n", xx, yy); string s; cin>>s; return s[0]=='t'; } int32_t main() { scanf("%d %d %d", &n, &x, &y); int l, r, two; two = 1; while(x+two<=n && interact(x+two, y)) two *= 2; l = x+(two/2); r = min(x+two, n); while(l<r) { int mid = (l+r+1)/2; if(interact(mid, y)) l = mid; else r = mid-1; } int right = l; two = 1; while(x-two>=1 && interact(x-two, y)) two *= 2; l = max(x-two, (int)1); r = x-(two/2); while(l<r) { int mid = (l+r)/2; if(interact(mid, y)) r = mid; else l = mid+1; } int left = l; two = 1; while(y+two<=n && interact(x, y+two)) two *= 2; l = y+(two/2); r = min(y+two, n); while(l<r) { int mid = (l+r+1)/2; if(interact(x, mid)) l = mid; else r = mid-1; } int top = l; two = 1; while(y-two>=1 && interact(x, y-two)) two *= 2; l = max(y-two, (int)1); r = y-(two/2); while(l<r) { int mid = (l+r)/2; if(interact(x, mid)) r = mid; else l = mid+1; } int bottom = l; m = right+1-left; int xc = (left+right)/2; int yc = (top+bottom)/2; while(xc-m>=1 && yc-m>=1 && interact(xc-m, yc-m)) { xc -= m; yc -= m; } while(xc-(2*m)>=1 && interact(xc-(2*m), yc)) xc -= 2*m; while(yc-(2*m)>=1 && interact(xc, yc-(2*m))) yc -= 2*m; xc += 2*m; yc += 2*m; printf("solution %lld %lld", xc, yc); }

Compilation message (stderr)

aliens.cpp: In function 'int32_t main()':
aliens.cpp:19:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   19 |     scanf("%d %d %d", &n, &x, &y);
      |            ~^         ~~
      |             |         |
      |             int*      long long int*
      |            %lld
aliens.cpp:19:16: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   19 |     scanf("%d %d %d", &n, &x, &y);
      |               ~^          ~~
      |                |          |
      |                int*       long long int*
      |               %lld
aliens.cpp:19:19: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   19 |     scanf("%d %d %d", &n, &x, &y);
      |                  ~^           ~~
      |                   |           |
      |                   int*        long long int*
      |                  %lld
aliens.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d %d %d", &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...