Submission #1068048

#TimeUsernameProblemLanguageResultExecution timeMemory
1068048PlurmArchery (IOI09_archery)C++11
15 / 100
2088 ms7120 KiB
#include <bits/stdc++.h> using namespace std; int n, r; int t; void one_round(vector<int> &archers) { vector<int> narchers(archers.begin(), archers.end()); for (int i = 2; i <= n; i++) { if (archers[2 * (i - 1)] < archers[2 * (i - 1) + 1]) { narchers[2 * (i - 2) + 1] = archers[2 * (i - 1)]; narchers[2 * (i - 1)] = archers[2 * (i - 1) + 1]; } else { narchers[2 * (i - 2) + 1] = archers[2 * (i - 1) + 1]; narchers[2 * (i - 1)] = archers[2 * (i - 1)]; } } if (archers[0] < archers[1]) { narchers[2 * (n - 1) + 1] = archers[1]; narchers[0] = archers[0]; } else { narchers[2 * (n - 1) + 1] = archers[0]; narchers[0] = archers[1]; } swap(archers, narchers); } void tournament(vector<int> &archers) { r %= 2 * (n - 1) * n; for (int i = 0; i < r; i++) { one_round(archers); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> r; int me; cin >> me; vector<int> archers; for (int i = 2; i <= 2 * n; i++) { int x; cin >> x; archers.push_back(x); } int ans = -1; int mn = 2 * n + 1; for (int i = 0; i < 2 * n; i++) { vector<int> tmp = archers; tmp.insert(tmp.begin() + i, me); tournament(tmp); int ending = find(tmp.begin(), tmp.end(), me) - tmp.begin(); if (ending <= mn) { mn = ending; ans = i / 2 + 1; } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...