답안 #1067937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067937 2024-08-21T05:48:32 Z thinknoexit Archery (IOI09_archery) C++17
16 / 100
2000 ms 856 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5050;
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]);
    }
    for (int _ = 1;_ <= min(r, 4 * n);_++) {
        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 (rnk == 1 || n + 1 < rnk) {
        for (int i = 0;i < n;i++) {
            if (val[i][0] == rnk || val[i][1] == rnk) return i;
        }
    }
    for (int i = 0;i < n;i++)
        if (val[i][0] == rnk || val[i][1] == rnk)
            return (i + (r - min(r, 4 * n))) % 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 Correct 0 ms 348 KB Output is correct
2 Execution timed out 2090 ms 348 KB Time limit exceeded
3 Correct 15 ms 344 KB Output is correct
4 Execution timed out 2055 ms 348 KB Time limit exceeded
5 Correct 0 ms 344 KB Output is correct
6 Correct 87 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Incorrect 96 ms 440 KB Output isn't correct
3 Execution timed out 2025 ms 600 KB Time limit exceeded
4 Runtime error 2 ms 600 KB Execution killed with signal 11
5 Runtime error 1 ms 604 KB Execution killed with signal 11
6 Correct 97 ms 348 KB Output is correct
7 Execution timed out 2029 ms 344 KB Time limit exceeded
8 Runtime error 2 ms 600 KB Execution killed with signal 11
9 Runtime error 1 ms 604 KB Execution killed with signal 11
10 Execution timed out 2097 ms 348 KB Time limit exceeded
11 Runtime error 1 ms 856 KB Execution killed with signal 11
12 Execution timed out 2079 ms 348 KB Time limit exceeded
13 Runtime error 1 ms 600 KB Execution killed with signal 11
14 Execution timed out 2021 ms 344 KB Time limit exceeded
15 Runtime error 1 ms 604 KB Execution killed with signal 11
16 Correct 96 ms 444 KB Output is correct
17 Execution timed out 2083 ms 348 KB Time limit exceeded
18 Execution timed out 2060 ms 348 KB Time limit exceeded
19 Execution timed out 2032 ms 348 KB Time limit exceeded
20 Execution timed out 2033 ms 344 KB Time limit exceeded
21 Runtime error 1 ms 600 KB Execution killed with signal 11
22 Runtime error 2 ms 604 KB Execution killed with signal 11
23 Runtime error 2 ms 688 KB Execution killed with signal 11
24 Correct 60 ms 440 KB Output is correct
25 Execution timed out 2070 ms 348 KB Time limit exceeded
26 Execution timed out 2069 ms 348 KB Time limit exceeded
27 Runtime error 1 ms 604 KB Execution killed with signal 11
28 Runtime error 2 ms 604 KB Execution killed with signal 11
29 Execution timed out 2098 ms 348 KB Time limit exceeded
30 Execution timed out 2050 ms 348 KB Time limit exceeded
31 Runtime error 2 ms 600 KB Execution killed with signal 11
32 Runtime error 1 ms 604 KB Execution killed with signal 11
33 Correct 84 ms 348 KB Output is correct
34 Correct 96 ms 344 KB Output is correct
35 Execution timed out 2017 ms 344 KB Time limit exceeded
36 Execution timed out 2024 ms 344 KB Time limit exceeded
37 Runtime error 1 ms 604 KB Execution killed with signal 11
38 Runtime error 1 ms 604 KB Execution killed with signal 11
39 Correct 84 ms 348 KB Output is correct
40 Execution timed out 2045 ms 348 KB Time limit exceeded
41 Execution timed out 2029 ms 344 KB Time limit exceeded
42 Execution timed out 2057 ms 348 KB Time limit exceeded
43 Execution timed out 2065 ms 348 KB Time limit exceeded
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