#include #include #include class player { public: int num; int current_player; bool is_reverse; bool toggle() { if (is_reverse) is_reverse = false; else is_reverse = true; return is_reverse; } void prev() { if (!is_reverse) { if (current_player - 1 < 0) { current_player = num - 1; return; } current_player--; } else { if (current_player + 1 > num - 1) { current_player = 0; return; } current_player++; } } void next() { if (!is_reverse) { if (current_player + 1 > num - 1) { current_player = 0; return; } current_player++; } else { if (current_player - 1 < 0) { current_player = num - 1; return; } current_player--; } } player(int num) : is_reverse(false), num(num) {} }; class Uno { public: std::vector card_num; int player_num; int log_num; player pobj; int drawfour; int drawtwo; Uno(int player_num, int log_num) : player_num(player_num), log_num(log_num), pobj(player_num), drawfour(0), drawtwo(0) { for (int x = 0; x < player_num; x++) { card_num.push_back(0); } } void draw() { if (drawfour != 0) { card_num[pobj.current_player] += drawfour; drawfour = 0; pobj.next(); } else if (drawtwo != 0) { card_num[pobj.current_player] += drawtwo; drawtwo = 0; pobj.next(); } } void turn(std::string s) { if (s == "reverse") { draw(); card_num[pobj.current_player] -= 1; pobj.toggle(); pobj.next(); } else if (s == "number") { draw(); card_num[pobj.current_player] -= 1; pobj.next(); } else if (s == "skip") { draw(); card_num[pobj.current_player] -= 1; pobj.next(); pobj.next(); } else if (s == "drawfour") { if (drawtwo) { card_num[pobj.current_player] += drawtwo; drawtwo = 0; pobj.next(); } card_num[pobj.current_player] -= 1; drawfour += 4; pobj.next(); } else if (s == "drawtwo") { if (drawfour) { card_num[pobj.current_player] += drawfour; drawfour = 0; pobj.next(); } card_num[pobj.current_player] -= 1; drawtwo += 2; pobj.next(); } } }; int main() { std::string str; int player_num, log_num; std::cin >> player_num >> log_num; Uno u(player_num, log_num); for (int i = 0; i < log_num; i++) { std::cin >> str; u.turn(str); } u.pobj.prev(); auto winner = u.pobj.current_player + 1; auto w = u.card_num[u.pobj.current_player] * -1; std::cout << winner << " " << w << std::endl; }