This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |