답안 #662105

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
662105 2022-11-26T06:56:19 Z Sohsoh84 Abracadabra (CEOI22_abracadabra) C++17
10 / 100
1982 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)			(x).begin(),(x).end()
#define X			first
#define Y			second
#define sep			' '
#define endl			'\n'
#define debug(x)		cerr << #x << ": " <<  x << endl;

const ll MAXN = 1e3 + 10;

vector<int> tmerge(vector<int> a, vector<int> b) {
	int pa = 0, pb = 0;
	vector<int> ans;
	while (pa < int(a.size()) || pb < int(b.size())) {
		if (pa == int(a.size()) || (pb < int(b.size()) && b[pb] < a[pa])) ans.push_back(b[pb++]);
		else ans.push_back(a[pa++]);
	}

	return ans;
}

int n, q;
vector<int> vec[MAXN];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> q;

	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		vec[0].push_back(x);
	}

	for (int i = 1; i < MAXN; i++) {
		vector<int> A[2];
		for (int j = 0; j < n; j++)
			A[j >= n / 2].push_back(vec[i - 1][j]);

		vec[i] = tmerge(A[0], A[1]);
	}

	while (q--) {
		int a, b;
		cin >> a >> b;
		a = min(1ll * a, MAXN - 1);
		cout << vec[a][b - 1] << endl;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 13260 KB Output is correct
2 Correct 213 ms 13636 KB Output is correct
3 Correct 209 ms 13168 KB Output is correct
4 Correct 189 ms 14148 KB Output is correct
5 Correct 210 ms 14200 KB Output is correct
6 Correct 196 ms 13768 KB Output is correct
7 Correct 202 ms 13516 KB Output is correct
8 Correct 190 ms 13340 KB Output is correct
9 Correct 226 ms 13516 KB Output is correct
10 Correct 189 ms 13552 KB Output is correct
11 Correct 194 ms 13196 KB Output is correct
12 Correct 194 ms 12784 KB Output is correct
13 Correct 186 ms 12688 KB Output is correct
14 Correct 196 ms 14692 KB Output is correct
15 Correct 191 ms 14540 KB Output is correct
16 Correct 16 ms 4348 KB Output is correct
17 Correct 189 ms 13516 KB Output is correct
18 Correct 182 ms 13492 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1982 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1520 ms 399884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 13260 KB Output is correct
2 Correct 213 ms 13636 KB Output is correct
3 Correct 209 ms 13168 KB Output is correct
4 Correct 189 ms 14148 KB Output is correct
5 Correct 210 ms 14200 KB Output is correct
6 Correct 196 ms 13768 KB Output is correct
7 Correct 202 ms 13516 KB Output is correct
8 Correct 190 ms 13340 KB Output is correct
9 Correct 226 ms 13516 KB Output is correct
10 Correct 189 ms 13552 KB Output is correct
11 Correct 194 ms 13196 KB Output is correct
12 Correct 194 ms 12784 KB Output is correct
13 Correct 186 ms 12688 KB Output is correct
14 Correct 196 ms 14692 KB Output is correct
15 Correct 191 ms 14540 KB Output is correct
16 Correct 16 ms 4348 KB Output is correct
17 Correct 189 ms 13516 KB Output is correct
18 Correct 182 ms 13492 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Runtime error 1982 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -