Submission #789124

# Submission time Handle Problem Language Result Execution time Memory
789124 2023-07-21T05:36:42 Z ymm Abracadabra (CEOI22_abracadabra) C++17
10 / 100
600 ms 524288 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;

vector<int> shf(vector<int> vec)
{
	int n = vec.size();
	vector<int> ans;
	int p0 = 0, p1 = n/2;
	Loop (_,0,n) {
		if (p1 == n || (p0 < n/2 && vec[p0] < vec[p1]))
			ans.push_back(vec[p0++]);
		else
			ans.push_back(vec[p1++]);
	}
	return ans;
}

vector<vector<int>> vecs;

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	vector<int> vec(n);
	for (int &x : vec)
		cin >> x;
	vecs.push_back(vec);
	for (;;) {
		vec = shf(vec);
		if (vecs.back() == vec)
			break;
		vecs.push_back(vec);
	}
	while (q--) {
		int t, i;
		cin >> t >> i;
		--i;
		t = min<int>(t, vecs.size()-1);
		cout << vecs[t][i] << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 178 ms 15792 KB Output is correct
2 Correct 176 ms 12520 KB Output is correct
3 Correct 207 ms 13180 KB Output is correct
4 Correct 170 ms 10248 KB Output is correct
5 Correct 181 ms 11956 KB Output is correct
6 Correct 151 ms 10824 KB Output is correct
7 Correct 174 ms 12272 KB Output is correct
8 Correct 150 ms 10720 KB Output is correct
9 Correct 151 ms 10444 KB Output is correct
10 Correct 186 ms 10656 KB Output is correct
11 Correct 150 ms 10652 KB Output is correct
12 Correct 188 ms 9548 KB Output is correct
13 Correct 152 ms 10260 KB Output is correct
14 Correct 157 ms 11320 KB Output is correct
15 Correct 156 ms 10564 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 149 ms 9728 KB Output is correct
18 Correct 149 ms 9628 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 600 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 461 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 15792 KB Output is correct
2 Correct 176 ms 12520 KB Output is correct
3 Correct 207 ms 13180 KB Output is correct
4 Correct 170 ms 10248 KB Output is correct
5 Correct 181 ms 11956 KB Output is correct
6 Correct 151 ms 10824 KB Output is correct
7 Correct 174 ms 12272 KB Output is correct
8 Correct 150 ms 10720 KB Output is correct
9 Correct 151 ms 10444 KB Output is correct
10 Correct 186 ms 10656 KB Output is correct
11 Correct 150 ms 10652 KB Output is correct
12 Correct 188 ms 9548 KB Output is correct
13 Correct 152 ms 10260 KB Output is correct
14 Correct 157 ms 11320 KB Output is correct
15 Correct 156 ms 10564 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 149 ms 9728 KB Output is correct
18 Correct 149 ms 9628 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Runtime error 600 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -