답안 #406498

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406498 2021-05-17T16:50:26 Z Aldas25 Archery (IOI09_archery) C++14
20 / 100
2000 ms 7736 KB
#pragma GCC optimize("O2")

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
//const ll MOD = 998244353;
const ll INF = 1e17;
const ld PI = asin(1) * 2;

int n, r;
vi seq;
int seq2[MAXN];
int x;

int a[MAXN], b[MAXN];

int check (int st) {

    //cout << " Check st = " << st << endl;

    st--;
    FOR(i, 0, 2*n-1){
        if (i/2 < st)
            seq2[i] = seq[i];
        else if (i/2 == st && (i%2 == 0))
            seq2[i] = x;
        else
            seq2[i] = seq[i-1];
    }

    FOR(t, 0, n-1) {
        a[t] = seq2[2*t];
        b[t] = seq2[2*t+1];
    }

   // cout << "   before Swap" << endl;
   //     FOR(t, 0, n-1)
   //         cout << "     t = " << t << " a = " << a[t] << " b = " << b[t] << endl;

    REP(2*n) {
        FOR(i, 0, n-1) {
            if (i == 0 && a[i] > b[i]) swap(a[i], b[i]);
            else if (i > 0 && a[i] < b[i]) swap(a[i], b[i]);
        }

        FOR(i, 0, n-2)
            swap(b[i],b[i+1]);

       // cout << "   after Swap" << endl;
       // FOR(t, 0, n-1)
       //     cout << "     t = " << t << " a = " << a[t] << " b = " << b[t] << endl;
    }

    int curT = 0;
    FOR(t, 0, n-1) {
        if (a[t] == x) return t;
        if (b[t] == x) curT = t;

        //cout << " t = " << t << " a = " << a[t] << " b = " << b[t] << endl;
    }

    curT = (curT - ((r-2*n)%n) + n)%n;
    return curT;
}

int main()
{
    FAST_IO;

    cin >> n >> r >> x;
    REP(2*n-1) {
        int p; cin >> p;
        seq.pb(p);
    }


    int ans = 1, mnTarget = n+1;
    FOR(i, 1, n) {
        int e = check(i);
        if (e <= mnTarget) {
            ans = i;
            mnTarget = e;
        }
    }

    cout << ans << "\n";

    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 352 KB Output is correct
2 Execution timed out 2053 ms 336 KB Time limit exceeded
3 Correct 6 ms 332 KB Output is correct
4 Execution timed out 2072 ms 332 KB Time limit exceeded
5 Correct 1 ms 332 KB Output is correct
6 Correct 33 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 39 ms 204 KB Output is correct
3 Execution timed out 2079 ms 332 KB Time limit exceeded
4 Execution timed out 2074 ms 972 KB Time limit exceeded
5 Execution timed out 2051 ms 6588 KB Time limit exceeded
6 Correct 34 ms 324 KB Output is correct
7 Execution timed out 2074 ms 332 KB Time limit exceeded
8 Execution timed out 2073 ms 972 KB Time limit exceeded
9 Execution timed out 2087 ms 1104 KB Time limit exceeded
10 Execution timed out 2068 ms 332 KB Time limit exceeded
11 Execution timed out 2065 ms 1104 KB Time limit exceeded
12 Execution timed out 2078 ms 460 KB Time limit exceeded
13 Execution timed out 2037 ms 4952 KB Time limit exceeded
14 Execution timed out 2080 ms 460 KB Time limit exceeded
15 Execution timed out 2074 ms 1488 KB Time limit exceeded
16 Correct 36 ms 332 KB Output is correct
17 Execution timed out 2081 ms 332 KB Time limit exceeded
18 Execution timed out 2065 ms 332 KB Time limit exceeded
19 Execution timed out 2080 ms 460 KB Time limit exceeded
20 Execution timed out 2084 ms 460 KB Time limit exceeded
21 Execution timed out 2084 ms 1104 KB Time limit exceeded
22 Execution timed out 2061 ms 1488 KB Time limit exceeded
23 Execution timed out 2076 ms 6972 KB Time limit exceeded
24 Correct 36 ms 332 KB Output is correct
25 Execution timed out 2072 ms 332 KB Time limit exceeded
26 Execution timed out 2085 ms 460 KB Time limit exceeded
27 Execution timed out 2085 ms 1104 KB Time limit exceeded
28 Execution timed out 2083 ms 5052 KB Time limit exceeded
29 Execution timed out 2085 ms 332 KB Time limit exceeded
30 Execution timed out 2092 ms 460 KB Time limit exceeded
31 Execution timed out 2085 ms 1104 KB Time limit exceeded
32 Execution timed out 2069 ms 6844 KB Time limit exceeded
33 Correct 38 ms 332 KB Output is correct
34 Correct 37 ms 332 KB Output is correct
35 Execution timed out 2094 ms 332 KB Time limit exceeded
36 Execution timed out 2061 ms 332 KB Time limit exceeded
37 Execution timed out 2073 ms 976 KB Time limit exceeded
38 Execution timed out 2097 ms 1232 KB Time limit exceeded
39 Correct 31 ms 332 KB Output is correct
40 Execution timed out 2060 ms 332 KB Time limit exceeded
41 Execution timed out 2081 ms 332 KB Time limit exceeded
42 Execution timed out 2068 ms 332 KB Time limit exceeded
43 Execution timed out 2058 ms 460 KB Time limit exceeded
44 Execution timed out 2088 ms 716 KB Time limit exceeded
45 Execution timed out 2063 ms 1104 KB Time limit exceeded
46 Execution timed out 2077 ms 1232 KB Time limit exceeded
47 Execution timed out 2081 ms 7736 KB Time limit exceeded