Submission #65100

# Submission time Handle Problem Language Result Execution time Memory
65100 2018-08-06T15:46:08 Z bazsi700 Cake (CEOI14_cake) C++14
0 / 100
372 ms 96784 KB
#include <bits/stdc++.h>

using namespace std;

struct Block {
    bool L;
    int prevblocksizesl;
    int prevblocksizesr;
    int siz;
    vector<pair<int,int> > tops;
};

int arr[250005];
vector<int> smallranks;

//14:45-19:45

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,A;
    cin >> n >> A;
    vector<pair<int,int> > tosort (n);
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
        tosort[i-1] = {arr[i],i};
    }
    sort(tosort.begin(),tosort.end());
    for(int i = 0; i <= 10; i++) {
        smallranks.push_back(tosort[i].second);
    }
    int Q;
    cin >> Q;
    vector<pair<int,int> > quer(Q);
    int fcn = 0;
    int ecn = 0;
    for(int i = 0; i < Q; i++) {
        char ch;
        cin >> ch;
        if(ch == 'F') {
            int pos;
            cin >> pos;
            quer[i] = {pos,-1};
            fcn++;
        } else {
            int pos,ran;
            cin >> pos >> ran;
            quer[i] = {pos,ran};
            ecn++;
        }
    }
    if((n <= 10000 && Q <= 10000) || fcn <= 500) {
        for(auto q : quer) {
            if(q.second == -1) {
                int pos = q.first;
                int leftind = A-1;
                int rightind = A+1;
                for(int i = 1; i < n; i++) {
                    if(leftind == 0) {
                        if(rightind == pos) {
                            cout << i << "\n";
                            break;
                        }
                        rightind++;
                        continue;
                    }
                    if(rightind == n+1) {
                        if(leftind == pos) {
                            cout << i << "\n";
                            break;
                        }
                        leftind--;
                        continue;
                    }
                    if(arr[leftind] < arr[rightind]) {
                        if(leftind == pos) {
                            cout << i << "\n";
                            break;
                        }
                        leftind--;
                        continue;
                    } else {
                        if(rightind == pos) {
                            cout << i << "\n";
                            break;
                        }
                        rightind++;
                        continue;
                    }
                }
            } else {
                int pos = q.first;
                int ran = q.second;
                bool cont = false;
                for(int el : smallranks) {
                    if(el == pos) {
                        cont = true;
                    }
                }
                if(!cont) {
                    vector<int> nwv;
                    for(int i = 0; i < ran-1; i++) {
                        nwv.push_back(smallranks[i]);
                    }
                    nwv.push_back(pos);
                    for(int i = ran; i < 10; i++) {
                        nwv.push_back(smallranks[i]);
                    }
                    swap(nwv,smallranks);
                } else {
                    vector<int> nwv;
                    for(int i = 0; i < ran-1; i++) {
                        nwv.push_back(smallranks[i]);
                    }
                    nwv.push_back(pos);
                    for(int i = ran; i <= 10; i++) {
                        if(smallranks[i] != pos) {
                            nwv.push_back(smallranks[i]);
                        }
                    }
                    swap(nwv,smallranks);
                }
                int prv = -1;
                for(int i = 0; i <= 10; i++) {
                    int el = smallranks[i];
                    if(el == pos) {
                        arr[el] = arr[smallranks[i+1]]+1;
                        break;
                    }
                    arr[el]++;
                }
            }
        }
    }
    return 0;
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:124:21: warning: unused variable 'prv' [-Wunused-variable]
                 int prv = -1;
                     ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 297 ms 8888 KB Output isn't correct
2 Incorrect 335 ms 13384 KB Output isn't correct
3 Runtime error 200 ms 22104 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 327 ms 26644 KB Output isn't correct
5 Incorrect 372 ms 31556 KB Output isn't correct
6 Incorrect 334 ms 36560 KB Output isn't correct
7 Incorrect 320 ms 41420 KB Output isn't correct
8 Incorrect 340 ms 46524 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 46524 KB Output isn't correct
2 Incorrect 43 ms 46940 KB Output isn't correct
3 Incorrect 47 ms 48348 KB Output isn't correct
4 Incorrect 2 ms 48348 KB Output isn't correct
5 Incorrect 112 ms 52524 KB Output isn't correct
6 Incorrect 86 ms 54964 KB Output isn't correct
7 Incorrect 100 ms 57588 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 57588 KB Output isn't correct
2 Incorrect 14 ms 57588 KB Output isn't correct
3 Incorrect 36 ms 57588 KB Output isn't correct
4 Incorrect 32 ms 57588 KB Output isn't correct
5 Incorrect 39 ms 58788 KB Output isn't correct
6 Incorrect 50 ms 61208 KB Output isn't correct
7 Incorrect 48 ms 62460 KB Output isn't correct
8 Incorrect 72 ms 66076 KB Output isn't correct
9 Incorrect 170 ms 76612 KB Output isn't correct
10 Incorrect 103 ms 77268 KB Output isn't correct
11 Incorrect 108 ms 81784 KB Output isn't correct
12 Incorrect 166 ms 89808 KB Output isn't correct
13 Incorrect 198 ms 96784 KB Output isn't correct