답안 #228727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
228727 2020-05-02T12:26:44 Z osaaateiasavtnl Archery (IOI09_archery) C++14
10 / 100
2000 ms 15552 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#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

const int N = 5e5 + 7;

void print(vector <int> a) {
    for (int i = 0; i < a.size(); ++i)  
        cout << a[i] << ' ';
    cout << endl;
}   

int get(vector <int> a, int x, int R) {
    if (a.size() == 2)
        return 0;

    //print(a);

    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;

        //cout << "new:\n";
        //print(a);
    }    
    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;
    int my;
    cin >> my;
    vector <int> p(2 * n - 1);
    for (int i = 0; i < 2 * n - 1; ++i)
        cin >> p[i];
    /*
    auto t = p;
    t.insert(t.begin() + 4, my);
    cout << get(t, my, R) << endl;
    exit(0);
    */
    int ans = N;
    int start = -1;
    for (int to = 0; to < 2 * n; ++to) {
        vector <int> t = p;
        t.insert(t.begin() + to, my);
        int nn = get(t, my, R);

        //cout << to << ' ' << nn << endl;

        if (nn <= ans) {
            ans = nn;
            start = to / 2;
        }   
    }       
    cout << start + 1 << endl;
}

Compilation message

archery.cpp: In function 'void print(std::vector<long long int>)':
archery.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)  
                     ~~^~~~~~~~~~
archery.cpp: In function 'long long int get(std::vector<long long int>, long long int, long long int)':
archery.cpp:29:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < a.size(); i += 2) {
                         ~~^~~~~~~~~~
archery.cpp:35:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 4; i < a.size(); i += 2) {
                         ~~^~~~~~~~~~
archery.cpp:45:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
archery.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
 }   
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Execution timed out 2074 ms 512 KB Time limit exceeded
3 Execution timed out 2077 ms 384 KB Time limit exceeded
4 Execution timed out 2079 ms 832 KB Time limit exceeded
5 Correct 6 ms 384 KB Output is correct
6 Execution timed out 2080 ms 384 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 384 KB Output is correct
2 Execution timed out 2069 ms 384 KB Time limit exceeded
3 Execution timed out 2084 ms 512 KB Time limit exceeded
4 Execution timed out 2088 ms 1552 KB Time limit exceeded
5 Execution timed out 2075 ms 13328 KB Time limit exceeded
6 Execution timed out 2083 ms 384 KB Time limit exceeded
7 Execution timed out 2085 ms 384 KB Time limit exceeded
8 Execution timed out 2083 ms 1424 KB Time limit exceeded
9 Execution timed out 2087 ms 1848 KB Time limit exceeded
10 Execution timed out 2072 ms 384 KB Time limit exceeded
11 Execution timed out 2084 ms 1840 KB Time limit exceeded
12 Execution timed out 2087 ms 656 KB Time limit exceeded
13 Execution timed out 2073 ms 9708 KB Time limit exceeded
14 Execution timed out 2032 ms 988 KB Time limit exceeded
15 Execution timed out 2085 ms 2696 KB Time limit exceeded
16 Correct 209 ms 384 KB Output is correct
17 Execution timed out 2075 ms 512 KB Time limit exceeded
18 Execution timed out 2084 ms 512 KB Time limit exceeded
19 Execution timed out 2074 ms 640 KB Time limit exceeded
20 Execution timed out 2076 ms 640 KB Time limit exceeded
21 Execution timed out 2078 ms 1844 KB Time limit exceeded
22 Execution timed out 2088 ms 2596 KB Time limit exceeded
23 Execution timed out 2088 ms 13944 KB Time limit exceeded
24 Correct 128 ms 384 KB Output is correct
25 Execution timed out 2072 ms 384 KB Time limit exceeded
26 Execution timed out 2084 ms 908 KB Time limit exceeded
27 Execution timed out 2073 ms 1844 KB Time limit exceeded
28 Execution timed out 2080 ms 9908 KB Time limit exceeded
29 Execution timed out 2080 ms 512 KB Time limit exceeded
30 Execution timed out 2087 ms 780 KB Time limit exceeded
31 Execution timed out 2080 ms 1860 KB Time limit exceeded
32 Execution timed out 2073 ms 13640 KB Time limit exceeded
33 Correct 181 ms 504 KB Output is correct
34 Execution timed out 2089 ms 384 KB Time limit exceeded
35 Execution timed out 2090 ms 632 KB Time limit exceeded
36 Execution timed out 2084 ms 512 KB Time limit exceeded
37 Execution timed out 2082 ms 1652 KB Time limit exceeded
38 Execution timed out 2081 ms 2168 KB Time limit exceeded
39 Execution timed out 2073 ms 384 KB Time limit exceeded
40 Execution timed out 2089 ms 384 KB Time limit exceeded
41 Execution timed out 2084 ms 512 KB Time limit exceeded
42 Execution timed out 2082 ms 512 KB Time limit exceeded
43 Execution timed out 2077 ms 768 KB Time limit exceeded
44 Execution timed out 2066 ms 1120 KB Time limit exceeded
45 Execution timed out 2058 ms 1860 KB Time limit exceeded
46 Execution timed out 2086 ms 1960 KB Time limit exceeded
47 Execution timed out 2076 ms 15552 KB Time limit exceeded