Submission #334592

#TimeUsernameProblemLanguageResultExecution timeMemory
334592rocks03Finding Routers (IOI20_routers)C++14
100 / 100
8 ms768 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int use_detector(int x); vector<int> ask; int use_use_detector(int x){ if(ask[x] != -1) return ask[x]; return (ask[x] = use_detector(x)); } vector<int> find_routers(int l, int n, int q){ ask.resize(l + 1, -1); vector<int> ans(n); vector<int> mn(n, 0), mx(n, l); ans[0] = 0; for(int i = 1; i < n; i++){ int l = max(mn[i-1], ans[i - 1]), r = mx[i]; while(r - l > 1){ int m = (l + r) / 2; int idx = use_use_detector(m); for(int j = idx; j < n; j++){ mn[j] = max(mn[j], m); } for(int j = idx; j >= 0; j--){ mx[j] = min(mx[j], m); } if(i <= idx){ r = m; } else{ l = m; } } ans[i] = 2 * (r - 1 - ans[i - 1]) + ans[i - 1]; } return ans; }

Compilation message (stderr)

routers.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization("O3")
      | 
routers.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...