Submission #891968

#TimeUsernameProblemLanguageResultExecution timeMemory
891968MackerArchery (IOI09_archery)C++17
18 / 100
2087 ms6712 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(v) v.begin(), v.end() #pragma GCC optimize("Ofast") #pragma GCC target("avx2") int main() { int n, r; cin >> n >> r; int me; cin >> me; vector<int> nv(2 * n - 1); for (auto &i : nv) { cin >> i; } nv.push_back(me); int mnp = -1; int mns = INT_MAX; for (int i = 2 * n - 1; i > 0; i--) { int mn = 0, mx = INT_MAX; vector<int> v = nv; int p = r; while(mn < mx){ mn = INT_MAX; mx = 0; for (int j = 1; j < n; j++) { mn = min(mn, max(v[2 * j], v[2 * j + 1])); mx = max(mx, min(v[2 * j], v[2 * j + 1])); } if(v[0] != 1) mn = 0; if(mn > mx) break; vector<int> tv(2 * n); if(v[0] > v[1]) swap(v[0], v[1]); tv[0] = v[0]; tv[2 * n - 1] = v[1]; for (int j = 1; j < n; j++) { int& s = v[2 * j], &b = v[2 * j + 1]; if(s < b) swap(s, b); tv[2 * j] = s; tv[2 * j - 1] = b; } v = tv; p--; } if(me > n || me == 1) p = 0; for (int j = 0; j < 2 * n; j++) { if(v[j] == me){ if((j / 2 - p + p * n) % n < mns){ mns = (j / 2 - p + p * n) % n; mnp = i / 2 + 1; } break; } } swap(nv[i], nv[i - 1]); } cout << mnp << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...