답안 #662762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
662762 2022-11-26T12:12:25 Z yoavL Abracadabra (CEOI22_abracadabra) C++17
10 / 100
1373 ms 524288 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <bitset>
#include <math.h>
#include <fstream>
#include <iomanip>
#include <functional>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;


using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using pb = pair<bool, bool>;
using vpb = vector<pb>;
using vvpb = vector<vpb>;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<int, int>;
using vpi = vector<pi>;

const ll inf = (ll)2e18;
const ll mod = (ll)(1e9 + 7);

#define FAST        ios_base::sync_with_stdio(0)
#define FASTIN		cin.tie(0)
#define FASTOUT		cout.tie(0)

#define upmin(a, b) (a) = min((a), (b))
#define upmax(a, b) (a) = max((a), (b))

#define pr(x) cout << x << endl
#define prv(v) for(auto it : v) cout << it << " "; cout << endl;
#define prvv(v) for(auto it : v) { for(auto it2 : it) cout << it2 << " "; cout << endl; } cout << endl;
#define spr(x) cout << x << " "

#define DBG_FLAG (1) // Toggle to switch between bebug mode and solution mode
#ifdef DBG_FLAG
#define wpr(x) cout << #x << ": " << (x) << endl;
#define wprv(v) cout << #v << ": " << endl; for(auto it : v) cout << it << " "; cout << endl;
#define wprvv(v) cout << #v << ": " << endl; for(auto it : v) { for(auto it2 : it) cout << it2 << " "; cout << endl; } cout << endl;
#define wspr(x) cout << #x << ": " << x << " "
#endif

#ifndef DBG_FLAG
#define wpr(x)
#define wprv(v)
#define wprvv(v)
#define wspr(x)
#endif

#define x first
#define y second

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back

ostream& operator<<(ostream& os, const pll& p)
{
	cout << "{" << p.first << ", " << p.second << "}" << endl;
	return os;
}


vll merge_cards(vll& arr)
{
	ll n = arr.size();
	ll p1 = 0, p2 = n / 2;
	vll res;
	while (res.size() < n) {
		if (p1 == n / 2) res.push_back(arr[p2++]);
		else if (p2 == n) res.push_back(arr[p1++]);
		else if (arr[p1] < arr[p2]) res.push_back(arr[p1++]);
		else res.push_back(arr[p2++]);
	}
	return res;
}

void solve()
{
	ll n, qNum;
	cin >> n >> qNum;
	vll arr(n);
	rep(i, 0, n) {
		cin >> arr[i];
	}

	vvll mat;
	mat.push_back(arr);
	while (true) {
		mat.push_back(merge_cards(mat.back()));
		if (mat.back() == mat[mat.size() - 2]) {
			mat.pop_back();
			break;
		}
	}
	

	while (qNum--) {
		ll qT, qInd;
		cin >> qT >> qInd;
		upmin(qT, (ll)mat.size() - (ll)1);
		pr(mat[qT][qInd - 1]);
	}
}


int32_t main()
{
	FAST;
	FASTIN; FASTOUT;
	solve();
}

Compilation message

Main.cpp: In function 'vll merge_cards(vll&)':
Main.cpp:96:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   96 |  while (res.size() < n) {
      |         ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1373 ms 15240 KB Output is correct
2 Correct 1306 ms 9240 KB Output is correct
3 Correct 1251 ms 11048 KB Output is correct
4 Correct 1222 ms 7112 KB Output is correct
5 Correct 1247 ms 8632 KB Output is correct
6 Correct 1194 ms 7964 KB Output is correct
7 Correct 1278 ms 8784 KB Output is correct
8 Correct 1198 ms 7656 KB Output is correct
9 Correct 1194 ms 7400 KB Output is correct
10 Correct 1211 ms 7568 KB Output is correct
11 Correct 1217 ms 7560 KB Output is correct
12 Correct 1189 ms 7088 KB Output is correct
13 Correct 1206 ms 7504 KB Output is correct
14 Correct 1268 ms 8040 KB Output is correct
15 Correct 1259 ms 7252 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1245 ms 7016 KB Output is correct
18 Correct 1200 ms 7000 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 507 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 465 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1373 ms 15240 KB Output is correct
2 Correct 1306 ms 9240 KB Output is correct
3 Correct 1251 ms 11048 KB Output is correct
4 Correct 1222 ms 7112 KB Output is correct
5 Correct 1247 ms 8632 KB Output is correct
6 Correct 1194 ms 7964 KB Output is correct
7 Correct 1278 ms 8784 KB Output is correct
8 Correct 1198 ms 7656 KB Output is correct
9 Correct 1194 ms 7400 KB Output is correct
10 Correct 1211 ms 7568 KB Output is correct
11 Correct 1217 ms 7560 KB Output is correct
12 Correct 1189 ms 7088 KB Output is correct
13 Correct 1206 ms 7504 KB Output is correct
14 Correct 1268 ms 8040 KB Output is correct
15 Correct 1259 ms 7252 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1245 ms 7016 KB Output is correct
18 Correct 1200 ms 7000 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Runtime error 507 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -