답안 #1067941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067941 2024-08-21T05:52:08 Z thinknoexit Archery (IOI09_archery) C++17
2 / 100
29 ms 604 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 404;
int a[2 * N];
int val[N][2];
int mx[N];
int n, r, rnk;
int cal() {
    for (int i = 0;i < n;i++) {
        val[i][0] = min(a[2 * i], a[2 * i + 1]);
        val[i][1] = max(a[2 * i], a[2 * i + 1]);
    }
    bool ch = 1;
    int nowr = r;
    do {
        ch = 1;
        for (int i = 0;i < n;i++) {
            if (i == 0) swap(val[i][0], val[i][1]);
            mx[i] = val[i][0];
        }
        for (int i = 0;i < n;i++) {
            val[i][0] = mx[(i + 1) % n];
            if (val[i][0] > val[i][1])
                swap(val[i][0], val[i][1]);
            if (i == 0 && val[i][0] != 1) ch = 0;
            if (i != 0 && val[i][1] <= n + 1) ch = 0;
        }
        nowr--;
    } while (nowr && !ch);
    for (int i = 0;i < n;i++)
        if (val[i][0] == rnk || val[i][1] == rnk)
            return (i + nowr) % n;
    return -1;
}
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> r;
    for (int i = 0;i < 2 * n;i++) cin >> a[i];
    rnk = a[0];
    int mn = n, idx = -1;
    for (int i = 0;i < 2 * n;i += 2) {
        if (i) swap(a[i], a[i - 2]);
        int val = cal();
        if (val <= mn) {
            mn = val;
            idx = i / 2;
        }
    }
    cout << idx + 1 << '\n';
    return 0;
}
/*
7 4
2 6
5 8
1 3
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Runtime error 0 ms 604 KB Execution killed with signal 11
3 Incorrect 3 ms 348 KB Output isn't correct
4 Runtime error 1 ms 604 KB Execution killed with signal 11
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 21 ms 348 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 23 ms 460 KB Output isn't correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Runtime error 1 ms 604 KB Execution killed with signal 11
5 Runtime error 0 ms 604 KB Execution killed with signal 11
6 Incorrect 17 ms 464 KB Output isn't correct
7 Runtime error 1 ms 604 KB Execution killed with signal 11
8 Runtime error 1 ms 404 KB Execution killed with signal 11
9 Runtime error 0 ms 604 KB Execution killed with signal 11
10 Runtime error 1 ms 604 KB Execution killed with signal 11
11 Runtime error 0 ms 604 KB Execution killed with signal 11
12 Runtime error 1 ms 604 KB Execution killed with signal 11
13 Runtime error 1 ms 604 KB Execution killed with signal 11
14 Runtime error 0 ms 604 KB Execution killed with signal 11
15 Runtime error 0 ms 604 KB Execution killed with signal 11
16 Incorrect 22 ms 460 KB Output isn't correct
17 Runtime error 1 ms 604 KB Execution killed with signal 11
18 Runtime error 0 ms 604 KB Execution killed with signal 11
19 Runtime error 0 ms 604 KB Execution killed with signal 11
20 Runtime error 0 ms 604 KB Execution killed with signal 11
21 Runtime error 1 ms 604 KB Execution killed with signal 11
22 Runtime error 0 ms 604 KB Execution killed with signal 11
23 Runtime error 0 ms 604 KB Execution killed with signal 11
24 Incorrect 29 ms 448 KB Output isn't correct
25 Runtime error 1 ms 604 KB Execution killed with signal 11
26 Runtime error 1 ms 604 KB Execution killed with signal 11
27 Runtime error 0 ms 604 KB Execution killed with signal 11
28 Runtime error 1 ms 604 KB Execution killed with signal 11
29 Runtime error 0 ms 604 KB Execution killed with signal 11
30 Runtime error 0 ms 604 KB Execution killed with signal 11
31 Runtime error 0 ms 604 KB Execution killed with signal 11
32 Runtime error 0 ms 604 KB Execution killed with signal 11
33 Incorrect 22 ms 348 KB Output isn't correct
34 Incorrect 22 ms 348 KB Output isn't correct
35 Runtime error 1 ms 604 KB Execution killed with signal 11
36 Runtime error 1 ms 604 KB Execution killed with signal 11
37 Runtime error 0 ms 604 KB Execution killed with signal 11
38 Runtime error 0 ms 604 KB Execution killed with signal 11
39 Incorrect 19 ms 452 KB Output isn't correct
40 Runtime error 1 ms 604 KB Execution killed with signal 11
41 Runtime error 1 ms 604 KB Execution killed with signal 11
42 Runtime error 0 ms 604 KB Execution killed with signal 11
43 Runtime error 1 ms 604 KB Execution killed with signal 11
44 Runtime error 1 ms 604 KB Execution killed with signal 11
45 Runtime error 1 ms 604 KB Execution killed with signal 11
46 Runtime error 1 ms 604 KB Execution killed with signal 11
47 Runtime error 1 ms 604 KB Execution killed with signal 11