Submission #468160

#TimeUsernameProblemLanguageResultExecution timeMemory
468160OzyWorm Worries (BOI18_worm)C++17
10 / 100
1 ms328 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define MAX 1000000 lli n,m,k,q,res; lli val[MAX+2]; lli ini,fin,mitad,a,b; lli pregunta(lli x, lli y, lli z) { cout << "? "<< x << ' '<< y << ' '<< z << endl; lli a; cin >> a; return a; } int main() { cin >> n >> m >> k >> q; ini = 0; fin = n+1; res = 0; while ((fin-ini) > 1) { mitad = (ini+fin)/2; if (val[mitad] == 0) val[mitad] = pregunta(mitad,1,1); if (val[mitad] >= val[ini] && val[mitad] >= val[fin]) { if ((fin-ini) == 2) {res = mitad; break;} else if ((fin-ini) == 3) {ini = mitad; continue;} a = (mitad + ini)/2; if (val[a] == 0) val[a] = pregunta(a,1,1); if (val[a] >= val[mitad]) {fin = mitad;continue;} b = (mitad + fin)/2; if (val[b] == 0) val[b] = pregunta(b,1,1); if (val[b] >= val[mitad]) {ini = mitad;continue;} ini = a; fin = b; } else { if (val[ini] >= val[fin]) fin = mitad; else ini = mitad; } } if (res == 0) res = (val[ini] >= val[fin]) ? ini : fin; cout << "! " << res << ' ' << 1 << ' ' << 1 << endl; }
#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...