2225.cpp (644B)
1 class Solution { 2 public: 3 vector<vector<int>> findWinners(const vector<vector<int>> &matches) { 4 static int count[100001]; 5 vector<vector<int>> res(2); 6 7 memset(count, 0xFF, sizeof(count)); 8 for (const auto &match : matches) { 9 if (count[match[0]] == -1) count[match[0]] = 0; 10 if (count[match[1]] == -1) count[match[1]] = 0; 11 count[match[1]]++; 12 } 13 14 for (int player = 1; player <= 100000; player++) { 15 if (count[player] == 0) res[0].push_back(player); 16 if (count[player] == 1) res[1].push_back(player); 17 } 18 return res; 19 } 20 };