Submission #662759

# Submission time Handle Problem Language Result Execution time Memory
662759 2022-11-26T12:11:29 Z yoavL Abracadabra (CEOI22_abracadabra) C++14
Compilation error
0 ms 0 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, 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) {
      |         ~~~~~~~~~~~^~~
Main.cpp: In function 'void solve()':
Main.cpp:54:39: error: no matching function for call to 'min(ll&, long long unsigned int)'
   54 | #define upmin(a, b) (a) = min((a), (b))
      |                                       ^
Main.cpp:128:3: note: in expansion of macro 'upmin'
  128 |   upmin(qT, mat.size() - (ll)1);
      |   ^~~~~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:54:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   54 | #define upmin(a, b) (a) = min((a), (b))
      |                                       ^
Main.cpp:128:3: note: in expansion of macro 'upmin'
  128 |   upmin(qT, mat.size() - (ll)1);
      |   ^~~~~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:54:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   54 | #define upmin(a, b) (a) = min((a), (b))
      |                                       ^
Main.cpp:128:3: note: in expansion of macro 'upmin'
  128 |   upmin(qT, mat.size() - (ll)1);
      |   ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from Main.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:54:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 | #define upmin(a, b) (a) = min((a), (b))
      |                                       ^
Main.cpp:128:3: note: in expansion of macro 'upmin'
  128 |   upmin(qT, mat.size() - (ll)1);
      |   ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from Main.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:54:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 | #define upmin(a, b) (a) = min((a), (b))
      |                                       ^
Main.cpp:128:3: note: in expansion of macro 'upmin'
  128 |   upmin(qT, mat.size() - (ll)1);
      |   ^~~~~