#include <bits/stdc++.h>
using namespace std;
#define EMT ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LINF = 2e18;
const double EPS = 1e-9;
signed main() { EMT
int n;
cin >> n;
int x, y;
cin >> x >> y;
vector<vector<int>> edge(n + 1);
for(int i = 1, a, b; i < n; i++) {
cin >> a >> b;
string s;
cin >> s;
edge[a].push_back(b);
edge[b].push_back(a);
}
vector<bool> vis(n + 1);
function<int(int, int)> dfs = [&](int u, int t) {
if(vis[u])
return -1;
vis[u] = 1;
if(u == t)
return 0;
for(int v : edge[u]) {
int x = dfs(v, t);
if(~x)
return x + 1;
}
return -1;
};
cout << (dfs(x, y) & 1 ? "Marin" : "Paula") << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
7788 KB |
Output is correct |
2 |
Correct |
55 ms |
7788 KB |
Output is correct |
3 |
Correct |
61 ms |
7788 KB |
Output is correct |
4 |
Correct |
55 ms |
7788 KB |
Output is correct |
5 |
Correct |
52 ms |
7788 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |