Submission #228740

# Submission time Handle Problem Language Result Execution time Memory
228740 2020-05-02T12:49:39 Z osaaateiasavtnl Archery (IOI09_archery) C++14
20 / 100
2000 ms 8156 KB
#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
int get(vector <int> a, int x, int R) {
    if (a.size() == 2)
        return 0;
    for (int t = 0; t < R; ++t) {
        for (int i = 0; i < a.size(); i += 2) {
            if (a[i] > a[i + 1])
                swap(a[i], a[i + 1]);
        }   
        vector <int> b = a;
        b[1] = a[2];
        for (int i = 4; i < a.size(); i += 2) {
            b[i - 2] = a[i];            
        }   
        b[(int)b.size() - 2] = a[1];
 
        a = b;
    }    
    for (int i = 0; i < a.size(); ++i)
        if (a[i] == x)
            return i / 2;
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, R;
    cin >> n >> R;
 
    R %= n;
    R += 2 * n;
 
    int my;
    cin >> my;
    vector <int> p(2 * n - 1);
    for (int i = 0; i < 2 * n - 1; ++i)
        cin >> p[i];
    int ans = 1e9;
    int start = -1;

    vector <int> nd(2 * n);

    for (int i = 0; i < 2 * n; ++i) {
        vector <int> t = p;
        t.insert(t.begin() + i, my);
        nd[i] = get(t, my, R);
    }       
    for (int i = 0; i < 2 * n; ++i) {
        if (nd[i] <= ans) {
            ans = nd[i];
            start = i / 2;
        }   
    }   

    int cnt = 0;
    for (int i = 0; i + 1 < 2 * n; ++i)
        cnt += nd[i] > nd[i + 1];
    if (cnt > 1) {
        cout << "LMAO" << endl;
    }

    /*
    for (int i = 0; i < 2 * n; ++i)
        cout << nd[i] << ' ';
    cout << endl;
    */

    #ifdef HOME
    cout << "ans : " << ans << endl;
    #endif
 
    cout << start + 1 << endl;
}

Compilation message

archery.cpp: In function 'int get(std::vector<int>, int, int)':
archery.cpp:16:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < a.size(); i += 2) {
                         ~~^~~~~~~~~~
archery.cpp:22:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 4; i < a.size(); i += 2) {
                         ~~^~~~~~~~~~
archery.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
archery.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
 }   
 ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Execution timed out 2081 ms 384 KB Time limit exceeded
3 Correct 21 ms 384 KB Output is correct
4 Execution timed out 2071 ms 384 KB Time limit exceeded
5 Correct 5 ms 384 KB Output is correct
6 Correct 96 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 123 ms 384 KB Output is correct
3 Execution timed out 2087 ms 384 KB Time limit exceeded
4 Execution timed out 2082 ms 988 KB Time limit exceeded
5 Execution timed out 2088 ms 6980 KB Time limit exceeded
6 Correct 97 ms 384 KB Output is correct
7 Execution timed out 2086 ms 384 KB Time limit exceeded
8 Execution timed out 2078 ms 1016 KB Time limit exceeded
9 Execution timed out 2083 ms 1284 KB Time limit exceeded
10 Execution timed out 2084 ms 384 KB Time limit exceeded
11 Execution timed out 2072 ms 1240 KB Time limit exceeded
12 Execution timed out 2088 ms 384 KB Time limit exceeded
13 Execution timed out 2084 ms 5168 KB Time limit exceeded
14 Execution timed out 2093 ms 708 KB Time limit exceeded
15 Execution timed out 2088 ms 1540 KB Time limit exceeded
16 Correct 119 ms 384 KB Output is correct
17 Execution timed out 2076 ms 384 KB Time limit exceeded
18 Execution timed out 2077 ms 384 KB Time limit exceeded
19 Execution timed out 2080 ms 632 KB Time limit exceeded
20 Execution timed out 2079 ms 864 KB Time limit exceeded
21 Execution timed out 2076 ms 1240 KB Time limit exceeded
22 Execution timed out 2085 ms 1552 KB Time limit exceeded
23 Execution timed out 2087 ms 7416 KB Time limit exceeded
24 Correct 115 ms 384 KB Output is correct
25 Execution timed out 2069 ms 384 KB Time limit exceeded
26 Execution timed out 2083 ms 764 KB Time limit exceeded
27 Execution timed out 2084 ms 1112 KB Time limit exceeded
28 Execution timed out 2092 ms 5276 KB Time limit exceeded
29 Execution timed out 2089 ms 384 KB Time limit exceeded
30 Execution timed out 2076 ms 792 KB Time limit exceeded
31 Execution timed out 2081 ms 1120 KB Time limit exceeded
32 Execution timed out 2085 ms 7200 KB Time limit exceeded
33 Correct 122 ms 384 KB Output is correct
34 Correct 111 ms 384 KB Output is correct
35 Execution timed out 2073 ms 384 KB Time limit exceeded
36 Execution timed out 2083 ms 384 KB Time limit exceeded
37 Execution timed out 2083 ms 1144 KB Time limit exceeded
38 Execution timed out 2089 ms 1340 KB Time limit exceeded
39 Correct 100 ms 396 KB Output is correct
40 Execution timed out 2082 ms 384 KB Time limit exceeded
41 Execution timed out 2082 ms 384 KB Time limit exceeded
42 Execution timed out 2088 ms 384 KB Time limit exceeded
43 Execution timed out 2043 ms 872 KB Time limit exceeded
44 Execution timed out 2082 ms 916 KB Time limit exceeded
45 Execution timed out 2051 ms 1120 KB Time limit exceeded
46 Execution timed out 2082 ms 1236 KB Time limit exceeded
47 Execution timed out 2078 ms 8156 KB Time limit exceeded