Submission #680599

#TimeUsernameProblemLanguageResultExecution timeMemory
680599Cross_RatioWorm Worries (BOI18_worm)C++14
32 / 100
34 ms616 KiB
#include <bits/stdc++.h> using namespace std; map<array<int, 3>, int> Ma; int N, M, K; int query_cnt = 0; int query(int a, int b, int c) { if(!(1<=a&&a<=N&&1<=b&&b<=M&&1<=c&&c<=K)) return -1; if(Ma.count({a, b, c})) return Ma[{a, b, c}]; query_cnt++; cout << "? " << a << ' ' << b << ' ' << c << endl; int d; cin >> d; Ma[{a, b, c}] = d; return d; } void answer(int a, int b, int c) { cout << "! " << a << ' ' << b << ' ' << c << endl; return; } int fibo[44]; void subtask_12() { int s = 1, e = fibo[30]+1; int x = fibo[28]+1, y = fibo[29]+1; while(s<=e) { if(s==e) { answer(s, 1, 1); return; } if(s+1==e) { if(query(s, 1, 1) >= query(e, 1, 1)) { answer(s, 1, 1); return; } else { answer(e, 1, 1); return; } } if(s+100>=e) { int mid = (s + e) / 2; if(query(mid, 1, 1) < query(mid+1, 1, 1)) { s = mid + 1; } else { e = mid; } continue; } if(query(x, 1, 1) >= query(y, 1, 1)) { e = y; y = x; x = (s+e) - y; } else { s = x; x = y; y = (s+e) - x; } } } void subtask_34() { int sx = 1, ex = N, sy = 1, ey = M; int rev = 0; int i, j; while(true) { if(sx==ex&&sy==ey) { answer(sx, sy, 1); return; } if(rev) { if(sx<ex) { int mid = (sx+ex)/2; int ma = -1, ix = -1; for(i=sy;i<=ey;i++) { for(int j = mid; j <= mid+1; j++) { if(ma < query(j, i, 1)) { ma = query(j, i, 1); ix = j; } } } if(ix==mid) ex = mid; else sx = mid + 1; } } else { if(sy<ey) { int mid = (sy+ey)/2; int ma = -1, iy = -1; for(i=sx;i<=ex;i++) { for(int j = mid; j <= mid+1; j++) { if(ma < query(i, j, 1)) { ma = query(i, j, 1); iy = j; } } } if(iy==mid) ey = mid; else sy = mid + 1; } } rev = 1 - rev; } } void subtask_56() { } signed main() { fibo[0] = fibo[1] = 1; int fibosum = 0; for(int i = 2 ; i <= 43; i++) { fibo[i] = fibo[i-1] + fibo[i-2]; //cout << i << " : " << fibo[i] << '\n'; } for(int i = 0; i <= 15; i++) fibosum += fibo[i]; //cout << fibosum*4 << '\n'; int Q; cin >> N >> M >> K >> Q; if(M==1 && K == 1) { subtask_12(); } else if(K==1 && N==M) { subtask_34(); } else if(K==N && K==M) { subtask_56(); } //cout << query_cnt; }

Compilation message (stderr)

worm.cpp: In function 'void subtask_34()':
worm.cpp:65:12: warning: unused variable 'j' [-Wunused-variable]
   65 |     int i, j;
      |            ^
#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...