Submission #680583

#TimeUsernameProblemLanguageResultExecution timeMemory
680583Cross_RatioWorm Worries (BOI18_worm)C++14
10 / 100
1 ms300 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]; int x = fibo[28], y = fibo[29]; 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+1000000>=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() { } void subtask_56() { } signed main() { fibo[0] = fibo[1] = 1; for(int i = 2 ; i <= 43; i++) { fibo[i] = fibo[i-1] + fibo[i-2]; //cout << i << " : " << fibo[i] << '\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; }
#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...