-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday55.cpp
More file actions
48 lines (40 loc) · 1.29 KB
/
day55.cpp
File metadata and controls
48 lines (40 loc) · 1.29 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <vector>
#include <string>
using namespace std;
// Function to determine the winner of the game
string determine_winner(int n, string starting_player, vector<int>& power_ups) {
int even_count = 0, odd_count = 0;
// Count the number of stations with even and odd power-ups
for (int i = 0; i < n; ++i) {
if (power_ups[i] % 2 == 0) {
even_count++;
} else {
odd_count++;
}
}
// Determine the winner based on the starting player and counts
if (starting_player == "Mario") {
// Mario wins if he can make the last move
return (even_count > odd_count) ? "Luigi" : (even_count < odd_count) ? "Mario" : "Luigi";
} else {
// Luigi wins if he can make the last move
return (odd_count > even_count) ? "Mario" : (odd_count < even_count) ? "Luigi" : "Mario";
}
}
int main() {
int t;
cin >> t; // Number of test cases
while (t--) {
int n;
string starting_player;
cin >> n >> starting_player;
vector<int> power_ups(n);
for (int i = 0; i < n; ++i) {
cin >> power_ups[i];
}
// Determine the winner for the current test case
cout <<determine_winner(n,starting_player,power_ups)<< endl;
}
return 0;
}