Submission #848713

# Submission time Handle Problem Language Result Execution time Memory
848713 2023-09-13T10:52:28 Z JoksimKaktus Abracadabra (CEOI22_abracadabra) C++17
10 / 100
309 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,q;
    cin >> n >> q;
    vector <int> v(n);
    int mini = 200000;
    vector <int> que[n*n];
    for(int i = 0;i < n;i++){
        cin >> v[i];
        que[0].push_back(v[i]);
        if(i < n/2){
            mini = min(mini,v[i]);
        }
    }
    int num = 1;
    while(num < n*n){
        vector<int> v1(n/2);
        vector<int> v2(n/2);
        for(int i = 0;i < n/2;i++){
            v1[i] = v[i];
            v2[i] = v[i+n/2];
        }
        int ind1 = 0;
        int ind2 = 0;
        while(ind1 < n/2 && ind2 < n/2){
            if(v1[ind1] < v2[ind2]){
                v[ind1+ind2] = v1[ind1];
                ind1++;
            }else{
                v[ind1+ind2] = v2[ind2];
                ind2++;
            }
        }
        if(ind1 < n/2){
            for(int i = ind1;i < n/2;i++){
                v[i+ind2] = v1[i];
            }
        }else{
            for(int i = ind2;i < n/2;i++){
                v[i+ind1] = v2[i];
            }
        }
        bool same = true;
        for(int i = 0;i < n;i++){
            que[num].push_back(v[i]);
            if(que[num][i] != que[num-1][i]){
                same = false;
            }
        }
        num++;
        if(same){
            break;
        }
    }

    for(int i = 0;i < q;i++){
        int a,b;
        cin >> a >> b;
        if(a >= num){
            cout << que[num-1][b-1] << "\n";
        }else {
            cout << que[a][b - 1] << "\n";
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 187 ms 34088 KB Output is correct
2 Correct 165 ms 31880 KB Output is correct
3 Correct 166 ms 31324 KB Output is correct
4 Correct 158 ms 29208 KB Output is correct
5 Correct 168 ms 31700 KB Output is correct
6 Correct 154 ms 28596 KB Output is correct
7 Correct 170 ms 31312 KB Output is correct
8 Correct 153 ms 28244 KB Output is correct
9 Correct 202 ms 30032 KB Output is correct
10 Correct 160 ms 28240 KB Output is correct
11 Correct 167 ms 29776 KB Output is correct
12 Correct 176 ms 27984 KB Output is correct
13 Correct 159 ms 27984 KB Output is correct
14 Correct 160 ms 30288 KB Output is correct
15 Correct 174 ms 29196 KB Output is correct
16 Correct 14 ms 23384 KB Output is correct
17 Correct 151 ms 27984 KB Output is correct
18 Correct 171 ms 28240 KB Output is correct
19 Correct 1 ms 500 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 309 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 262 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 187 ms 34088 KB Output is correct
2 Correct 165 ms 31880 KB Output is correct
3 Correct 166 ms 31324 KB Output is correct
4 Correct 158 ms 29208 KB Output is correct
5 Correct 168 ms 31700 KB Output is correct
6 Correct 154 ms 28596 KB Output is correct
7 Correct 170 ms 31312 KB Output is correct
8 Correct 153 ms 28244 KB Output is correct
9 Correct 202 ms 30032 KB Output is correct
10 Correct 160 ms 28240 KB Output is correct
11 Correct 167 ms 29776 KB Output is correct
12 Correct 176 ms 27984 KB Output is correct
13 Correct 159 ms 27984 KB Output is correct
14 Correct 160 ms 30288 KB Output is correct
15 Correct 174 ms 29196 KB Output is correct
16 Correct 14 ms 23384 KB Output is correct
17 Correct 151 ms 27984 KB Output is correct
18 Correct 171 ms 28240 KB Output is correct
19 Correct 1 ms 500 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Runtime error 309 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -