From 96254947699986c59f0dc63d69fd4b76bd3ed43e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Jul 2026 19:08:08 +0200 Subject: Initial commit --- 01_introductory_problems/raab_game_i_3399.cpp | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 01_introductory_problems/raab_game_i_3399.cpp (limited to '01_introductory_problems/raab_game_i_3399.cpp') diff --git a/01_introductory_problems/raab_game_i_3399.cpp b/01_introductory_problems/raab_game_i_3399.cpp new file mode 100644 index 0000000..bfa5193 --- /dev/null +++ b/01_introductory_problems/raab_game_i_3399.cpp @@ -0,0 +1,67 @@ +#include +#include +#include + +class Game { +public: + bool y; + std::vector a; + std::vector b; + int apts = 0; + int bpts = 0; + + Game(int n, bool w) + : y{w}, a{std::vector(n)}, b{std::vector(n)} {} + + void play(int i, int j) { + this->a[this->next] = i; + this->b[this->next] = j; + this->apts += i > j; + this->bpts += j > i; + this->next++; + } + + friend std::ostream& operator<<(std::ostream& os, const Game g) { + if (!g.y) { + os << "NO\n"; + } else { + os << "YES\n"; + for (auto x : g.a) + os << x << " "; + os << "\n"; + for (auto x : g.b) + os << x << " "; + os << "\n"; + } + return os; + } +private: + int next = 0; +}; + +Game play(int n, int a, int b) { + if (a + b > n) + return Game(1, false); + + Game g(n, true); + for (int i = 0; i < n - (a+b); i++) + g.play(i+1, i+1); + for (int i = 0; i < a; i++) + g.play(n-a+i+1, n-(a+b)+i+1); + for (int i = 0; i < b; i++) + g.play(n-(a+b)+i+1, n-b+i+1); + + if (g.apts != a || g.bpts != b) + g.y = false; + + return g; +} + +int main() { + int n, a, b, t; + std::cin >> t; + for (int i = 0; i < t; i++) { + std::cin >> n >> a >> b; + std::cout << play(n, a, b); + } +} -- cgit v1.3