Submission #271644

# Submission time Handle Problem Language Result Execution time Memory
271644 2020-08-18T07:07:31 Z 반딧불(#5113) Archery (IOI09_archery) C++17
16 / 100
52 ms 384 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

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);
    if(n>200) return 1;
    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:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   35 |     scanf("%d %d %d", &n, &k, &val);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
archery.cpp:38:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |     for(int i=2; i<=2*n; i++) scanf("%d", &arr[i]);
      |                               ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
3 Correct 5 ms 256 KB Output is correct
4 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
5 Correct 1 ms 256 KB Output is correct
6 Correct 32 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Incorrect 30 ms 256 KB Output isn't correct
3 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
5 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
6 Correct 29 ms 256 KB Output is correct
7 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
8 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
9 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
10 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
11 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
13 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
16 Correct 30 ms 288 KB Output is correct
17 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
18 Runtime error 0 ms 288 KB Execution failed because the return code was nonzero
19 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
20 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
21 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
22 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
23 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
24 Correct 52 ms 364 KB Output is correct
25 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
26 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
27 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
28 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
29 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
30 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
31 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
32 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
33 Correct 31 ms 256 KB Output is correct
34 Correct 31 ms 384 KB Output is correct
35 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
36 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
37 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
38 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
39 Correct 27 ms 360 KB Output is correct
40 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
41 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
42 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
43 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
44 Runtime error 0 ms 256 KB Execution failed because the return code was nonzero
45 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
46 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
47 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero