CSES - Datatähti 2025 alku - Results
Submission details
Task:Kortit I
Sender:fatihmerickoc
Submission time:2024-10-28 20:05:01 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'void solve_game(int, std::vector<std::tuple<int, int, int> >)':
input/code.cpp:15:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for (const auto& [n, a, b] : test_cases) {
      |                      ^
input/code.cpp:15:22: error: structured binding refers to incomplete type 'const std::tuple<int, int, int>'
   15 |     for (const auto& [n, a, b] : test_cases) {
      |                      ^~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:60:25: error: 'make_tuple' was not declared in this scope
   60 |         test_cases[i] = make_tuple(n, a, b);
      |                         ^~~~~~~~~~
input/code.cpp:12:1: note: 'std::make_tuple' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
   11 | #include <algorithm>
  +++ |+#include <tuple>
   12 | using namespace std;
In file included from /usr/include/c++/11/bits/stl_algobase.h:67,
                 from /usr/include/c++/11/...

Code

//
//  main.cpp
//  cpp
//
//  Created by Fatih Meric Koc on 28.10.2024.
//

#include <iostream>

#include <vector>
#include <algorithm>
using namespace std;

void solve_game(int t, vector<tuple<int, int, int>> test_cases) {
    for (const auto& [n, a, b] : test_cases) {
        if (a + b > n) {
            cout << "NO" << endl;
            continue;
        }

        vector<int> player1(n), player2(n);
        for (int i = 0; i < n; ++i) {
            player1[i] = i + 1;
            player2[i] = i + 1;
        }

        sort(player1.begin(), player1.end());
        sort(player2.rbegin(), player2.rend());

        int a_count = a, b_count = b;
        for (int i = 0; i < n; ++i) {
            if (a_count > 0 && player1[i] < player2[i]) {
                --a_count;
            } else if (b_count > 0 && player1[i] > player2[i]) {
                --b_count;
            } else {
                player2[i] = player1[i];
            }
        }

        cout << "YES" << endl;
        for (int i = 0; i < n; ++i) {
            cout << player1[i] << " ";
        }
        cout << endl;
        for (int i = 0; i < n; ++i) {
            cout << player2[i] << " ";
        }
        cout << endl;
    }
}

int main() {
    int t;
    cin >> t;
    vector<tuple<int, int, int>> test_cases(t);
    for (int i = 0; i < t; ++i) {
        int n, a, b;
        cin >> n >> a >> b;
        test_cases[i] = make_tuple(n, a, b);
    }

    solve_game(t, test_cases);

    return 0;
}