Submission #1261256

#TimeUsernameProblemLanguageResultExecution timeMemory
1261256Zbyszek99Worm Worries (BOI18_worm)C++20
0 / 100
3076 ms416 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define ull unsigned long long #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vl vector<long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define siz(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} ll los(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; ld c1 = ((ld)sqrt(5)-1)/2; ld c2 = 1-c1; ll n,m,k,q; map<ll,int> query_map; int ask(int x) { int y = 1; int z = 1; if(x < 1 || x > n || y < 1 || y > m || z < 1 || z > k) return 0; int h = x-1 + (y-1)*n + (z-1)*n*m; if(query_map.find(h) != query_map.end()) return query_map[h]; cout << "? " << x << " " << y << " " << z << endl; cin >> query_map[h]; return query_map[h]; } void solve(int l, int r, int q1, int q2) { q1 = min(r,q1); q1 = max(l,q1); q2 = min(r,q2); q2 = max(l,q2); if(q1 == q2) { ll d1 = l*c1+r*c2; ll d2 = l*c2+r*c1; if(abs(d1-q1) > abs(d2-q1)) q2 = d2; else q2 = d1; } if(q1 > q2) swap(q1,q2); if(r-l+1 <= 1) { rep2(i,l,r) { if(ask(i) >= ask(i-1) && ask(i) >= ask(i+1)) { cout << "! " << i << " 1 1\n"; return; } } } int v1 = ask(q1); int v2 = ask(q2); if(v1 > v2) { solve(l,q2-1,q1,c2*(ld)l+(ld)(q2-1)*c1); } else { solve(q1+1,r,q2,(ld)(q1+1)*c2+(ld)r*c1); } } int main() { cin >> n >> m >> k >> q; ll l = (ld)n*c2; ll r = (ld)n*c1; // cout << l << " " << r << " " << (ld)n*c << " " << c << " lr\n"; solve(1,n,l,r); }
#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...