Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- void ProcessOneTest(size_t number_of_test) {
- size_t rows, colums, escape;
- std::cin >> rows >> colums >> escape;
- if (escape == rows*colums - 1) {
- std::cout << "Case #" << number_of_test << ": "<< "IMPOSSIBLE\n";
- return;
- }
- if (colums == 1) {
- std::cout << "Case #" << number_of_test << ": "<< "POSSIBLE\n";
- for (size_t index = 0; index < rows - escape; ++index) {
- if (index != rows - escape - 1) {
- std::cout << "S\n";
- } else {
- std::cout << "N\n";
- }
- }
- for (size_t index = rows - escape; index < rows; ++index) {
- std::cout << "S\n";
- }
- return;
- }
- std::vector<std::vector<char>> doors(rows, std::vector<char>(colums, ' '));
- size_t id = 0;
- do {
- if (escape < colums) {
- break;
- }
- escape -= colums;
- for (size_t index = 0; index < colums; ++index) {
- doors[id][index] = 'E';
- }
- ++id;
- } while (true);
- if (escape != 0) {
- if (escape != colums - 1) {
- for (size_t index = 0; index < colums - escape; ++index) {
- if (index != colums - escape - 1) {
- doors[id][index] = 'E';
- } else {
- doors[id][index] = 'W';
- }
- }
- for (size_t index = colums - escape; index < colums; ++index) {
- doors[id][index] = 'E';
- }
- ++id;
- } else {
- for (size_t index = 1; index < colums; ++index) {
- doors[id][index] = 'E';
- }
- doors[id][0] = 'S';
- ++id;
- doors[id][0] = 'N';
- for (size_t index = 1; index < colums; ++index) {
- if (index != colums - 1) {
- doors[id][index] = 'E';
- } else {
- doors[id][index] = 'W';
- }
- }
- ++id;
- }
- }
- while (id != rows) {
- for (size_t index = 0; index < colums; ++index) {
- if (index != colums - 1) {
- doors[id][index] = 'E';
- } else {
- doors[id][index] = 'W';
- }
- }
- ++id;
- }
- std::cout << "Case #" << number_of_test << ": POSSIBLE\n";
- for (size_t index_first = 0; index_first < rows; ++index_first) {
- for (size_t index_second = 0; index_second < colums; ++index_second) {
- std::cout << doors[index_first][index_second];
- }
- std::cout << '\n';
- }
- }
- int main() {
- std::ios_base::sync_with_stdio(false);
- std::cin.tie(nullptr);
- size_t t;
- std::cin >> t;
- for (size_t number_of_test = 1; number_of_test <= t; ++number_of_test) {
- ProcessOneTest(number_of_test);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement