제출 #1068064

#제출 시각아이디문제언어결과실행 시간메모리
1068064PlurmArchery (IOI09_archery)C++11
19 / 100
2095 ms5064 KiB
#include <bits/stdc++.h> using namespace std; int n, r; int t; void one_round(vector<int> &archers) { vector<int> narchers(archers.size()); 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) { for (int i = 0; i < r; i++) { one_round(archers); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> r; r %= (n - 1) * n / 2; 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...