#include <iostream> #include <vector> int main() { int n; int t; int num_cards; int card; std::vector<int> cards; std::cin >> n >> t; num_cards = 1 << n; if(t % 2) { cards.resize(num_cards); for(int i = 0; i < num_cards; ++i) { std::cin >> cards[i]; } for(int i = num_cards - 1; i > 0; --i) { std::cout << cards[i] << " "; } std::cout << cards[0]; } else { for(int i = 0; i < num_cards - 1; ++i) { std::cin >> card; std::cout << card << " "; } std::cin >> card; std::cout << card; } std::cout << std::endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <iostream> #include <vector> int main() { int n; int t; int num_cards; int card; std::vector<int> cards; std::cin >> n >> t; num_cards = 1 << n; if(t % 2) { cards.resize(num_cards); for(int i = 0; i < num_cards; ++i) { std::cin >> cards[i]; } for(int i = num_cards - 1; i > 0; --i) { std::cout << cards[i] << " "; } std::cout << cards[0]; } else { for(int i = 0; i < num_cards - 1; ++i) { std::cin >> card; std::cout << card << " "; } std::cin >> card; std::cout << card; } std::cout << std::endl; return 0; } |