답안 #1067983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067983 2024-08-21T06:23:49 Z thinknoexit Archery (IOI09_archery) C++17
10 / 100
2000 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 = 0;
    int nowr = r;
    for (int _ = 1;_ <= n * n && nowr;_++) {
        ch = 0;
        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]);
        }
        nowr--;
    }
    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
*/

Compilation message

archery.cpp: In function 'int cal()':
archery.cpp:14:10: warning: variable 'ch' set but not used [-Wunused-but-set-variable]
   14 |     bool ch = 0;
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Correct 260 ms 348 KB Output is correct
4 Runtime error 1 ms 600 KB Execution killed with signal 11
5 Incorrect 0 ms 348 KB Output isn't correct
6 Execution timed out 2091 ms 348 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Execution timed out 2084 ms 348 KB Time limit exceeded
3 Runtime error 1 ms 600 KB Execution killed with signal 11
4 Runtime error 1 ms 600 KB Execution killed with signal 11
5 Runtime error 1 ms 604 KB Execution killed with signal 11
6 Execution timed out 2041 ms 348 KB Time limit exceeded
7 Runtime error 1 ms 604 KB Execution killed with signal 11
8 Runtime error 1 ms 604 KB Execution killed with signal 11
9 Runtime error 0 ms 604 KB Execution killed with signal 11
10 Runtime error 0 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 1 ms 548 KB Execution killed with signal 11
16 Correct 96 ms 348 KB Output is correct
17 Runtime error 1 ms 600 KB Execution killed with signal 11
18 Runtime error 1 ms 604 KB Execution killed with signal 11
19 Runtime error 1 ms 604 KB Execution killed with signal 11
20 Runtime error 1 ms 604 KB Execution killed with signal 11
21 Runtime error 1 ms 604 KB Execution killed with signal 11
22 Runtime error 1 ms 604 KB Execution killed with signal 11
23 Runtime error 1 ms 604 KB Execution killed with signal 11
24 Correct 55 ms 348 KB Output is correct
25 Runtime error 1 ms 600 KB Execution killed with signal 11
26 Runtime error 1 ms 604 KB Execution killed with signal 11
27 Runtime error 1 ms 600 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 1 ms 600 KB Execution killed with signal 11
32 Runtime error 1 ms 604 KB Execution killed with signal 11
33 Correct 75 ms 436 KB Output is correct
34 Execution timed out 2029 ms 344 KB Time limit exceeded
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 1 ms 604 KB Execution killed with signal 11
38 Runtime error 1 ms 604 KB Execution killed with signal 11
39 Execution timed out 2095 ms 348 KB Time limit exceeded
40 Runtime error 1 ms 604 KB Execution killed with signal 11
41 Runtime error 0 ms 604 KB Execution killed with signal 11
42 Runtime error 1 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