이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) {
    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 time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |