답안 #271604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
271604 2020-08-18T06:57:17 Z 반딧불(#5113) Archery (IOI09_archery) C++17
16 / 100
2000 ms 512 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k, val;
int arr[405];
int ans, finish = 1e9;

int tryIfAble(){
    vector<int> v(arr+1, arr+2*n+1);
    int cnt = 2*n;
    while(cnt--){
        for(int i=0; i<n; i++){
            if(i==0 && v[i*2] > v[i*2+1]) swap(v[i*2], v[i*2+1]);
            else if(i && v[i*2] < v[i*2+1]) swap(v[i*2], v[i*2+1]);
        }
        int tmp = v[1];
        for(int i=0; i<n-1; i++) v[i*2+1] = v[i*2+3];
        v.back()=tmp;
    }

    int idx = -1;
    for(int i=0; i<2*n; i++) if(v[i] == val) idx = i;
    if(idx%2==0) return idx/2+1;
    idx /= 2, idx += (k-n-n), idx %= n, idx++;
    return idx;
}

int main(){
    scanf("%d %d %d", &n, &k, &val);
    arr[1] = val;
    for(int i=2; i<=2*n; i++) scanf("%d", &arr[i]);

    for(int i=1; i<=2*n; i+=2){
        int tmp = tryIfAble();
        if(finish >= tmp) finish = tmp, ans = (i+1)/2;

        swap(arr[i], arr[i+1]);
        swap(arr[i+1], arr[i+2]);
    }
    printf("%d\n", ans);
}

Compilation message

archery.cpp: In function 'int main()':
archery.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |     scanf("%d %d %d", &n, &k, &val);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
archery.cpp:34:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |     for(int i=2; i<=2*n; i++) scanf("%d", &arr[i]);
      |                               ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 547 ms 372 KB Output isn't correct
3 Correct 5 ms 256 KB Output is correct
4 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
5 Correct 1 ms 256 KB Output is correct
6 Correct 35 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Incorrect 45 ms 376 KB Output isn't correct
3 Execution timed out 2079 ms 384 KB Time limit exceeded
4 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
5 Execution timed out 2 ms 384 KB Time limit exceeded (wall clock)
6 Correct 45 ms 256 KB Output is correct
7 Execution timed out 2079 ms 256 KB Time limit exceeded
8 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
9 Execution timed out 2 ms 384 KB Time limit exceeded (wall clock)
10 Execution timed out 2073 ms 384 KB Time limit exceeded
11 Execution timed out 2 ms 384 KB Time limit exceeded (wall clock)
12 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
13 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
14 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
15 Execution timed out 2 ms 488 KB Time limit exceeded (wall clock)
16 Correct 40 ms 256 KB Output is correct
17 Execution timed out 2075 ms 384 KB Time limit exceeded
18 Execution timed out 2075 ms 384 KB Time limit exceeded
19 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
20 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
21 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
22 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
23 Execution timed out 2 ms 384 KB Time limit exceeded (wall clock)
24 Correct 40 ms 256 KB Output is correct
25 Incorrect 744 ms 504 KB Output isn't correct
26 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
27 Runtime error 870 ms 504 KB Execution killed with signal 11
28 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
29 Execution timed out 2056 ms 384 KB Time limit exceeded
30 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
31 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
32 Execution timed out 2 ms 384 KB Time limit exceeded (wall clock)
33 Correct 39 ms 256 KB Output is correct
34 Correct 41 ms 256 KB Output is correct
35 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
36 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
37 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
38 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
39 Correct 33 ms 256 KB Output is correct
40 Incorrect 462 ms 504 KB Output isn't correct
41 Runtime error 2 ms 512 KB Execution killed with signal 11
42 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
43 Execution timed out 2 ms 384 KB Time limit exceeded (wall clock)
44 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
45 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
46 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
47 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)