Submission #710769

# Submission time Handle Problem Language Result Execution time Memory
710769 2023-03-15T18:13:03 Z Jarif_Rahman Homework (CEOI22_homework) C++17
0 / 100
1 ms 468 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, q; cin >> n >> q;
    vector<int> v(n);
    for(int &x: v) cin >> x, x--;

    vector<tuple<int, int, int>> queries;
    for(int i = 0; i < q; i++){
        int t, I; cin >> t >> I; I--;
        queries.pb({t, I, i});
    }

    sort(queries.begin(), queries.end());
    vector<int> ans(q);

    auto it = queries.begin();
    int c = 0;
    while(it != queries.end() && get<0>(*it) == 0) ans[get<2>(*it)] = v[get<1>(*it)], it++;

    while(1){
        auto _v = v;
        merge(_v.begin(), _v.begin()+n/2, _v.begin()+n/2, _v.begin()+n, v.begin());
        c++;

        while(it != queries.end() && get<0>(*it) <= c) ans[get<2>(*it)] = v[get<1>(*it)], it++;

        if(v == _v) break;
    }

    while(it != queries.end()) ans[get<2>(*it)] = v[get<1>(*it)], it++;

    for(int x: ans) cout << x+1 << "\n";
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -