Task: | Kortit I |
Sender: | Arkistoija |
Submission time: | 2024-11-05 10:56:52 +0200 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from input/code.cpp:1: /usr/include/c++/11/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<int, std::pmr::polymorphic_allocator<int> >': /usr/include/c++/11/bits/stl_vector.h:389:11: required from 'class std::vector<int, std::pmr::polymorphic_allocator<int> >' input/code.cpp:33:30: required from here /usr/include/c++/11/bits/stl_vector.h:87:28: error: invalid use of incomplete type 'class std::pmr::polymorphic_allocator<int>' 87 | rebind<_Tp>::other _Tp_alloc_type; | ^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/functional:61, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74,...
Code
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int rounds; int cards, player_a, player_b; cin >> rounds; int bases [rounds][3]; for (int i = 0; i < rounds; i++) { cin >> cards >> player_a >> player_b; bases [i][0] = cards; bases [i][1] = player_a; bases [i][2] = player_b; } for (int i = 0; i < rounds; i++) { if (bases[i][0] < (bases[i][1] + bases[i][2])) { // cout << "wins " << bases[i][0] << ",a + b " << (bases[i][1] + bases[i][2]) << endl; cout << "NO\n"; } else if (bases[i][1] + bases[i][2] == 1) { cout << "NO\n"; } else { cout << "YES\n"; pmr::vector<int> player_a_hand; pmr::vector<int> player_b_hand; for (int k = bases[i][0]; k > 0 ; k--) { player_a_hand.push_back(k); player_b_hand.push_back(k); } int draws = bases[i][0] - (bases[i][1] + bases[i][2]); string hand_1 = ""; string hand_2 = ""; for (int d = 1; d < draws+1; d++) { string new_hand = to_string(d) + " "; hand_1 += new_hand; hand_2 += new_hand; player_a_hand.pop_back(); player_b_hand.pop_back(); } sort(player_b_hand.begin(), player_b_hand.end()); for (int player_a_wins = 0; player_a_wins < bases[i][2]; player_a_wins++ ) { if (player_a_hand.back() == player_b_hand.back()){ cout << "PROBLEM"; char c = hand_2.at(1); string end_card = " "; cout << hand_2.front() << hand_2.at(1) << endl; if (isspace(c)) { end_card = to_string(hand_2.front()); hand_2.erase(0, 2); string new_hand_2 = to_string(player_b_hand.back()) + " " + hand_2 + end_card + " "; hand_2 = new_hand_2; } else { end_card = to_string(hand_2.front()) + to_string(hand_2.at(1)); hand_2.erase(0, 3); string new_hand_2 = to_string(player_b_hand.back()) + " " + hand_2 + end_card + " "; hand_2 = new_hand_2; } player_b_hand.pop_back(); int new_hand_a = player_a_hand.back(); hand_1 += to_string(new_hand_a) + " "; player_a_hand.pop_back(); } else { int new_hand_a = player_a_hand.back(); hand_1 += to_string(new_hand_a) + " "; player_a_hand.pop_back(); int new_hand_b = player_b_hand.back(); hand_2 += to_string(new_hand_b) + " "; player_b_hand.pop_back(); } } sort(player_a_hand.begin(), player_a_hand.end()); sort(player_b_hand.begin(), player_b_hand.end()); for (int player_b_wins = 0; player_b_wins < bases[i][1]; player_b_wins++ ) { int new_hand_a = player_a_hand.back(); hand_1 += to_string(new_hand_a) + " "; player_a_hand.pop_back(); int new_hand_b = player_b_hand.back(); hand_2 += to_string(new_hand_b) + " "; player_b_hand.pop_back(); } cout << hand_1 << "\n"; cout << hand_2 << "\n"; } } return 0; }