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 ll long long
vector<vector<vector<int>>> ve;
vector<int> dist;
void dfs(int x, int p, int depth){
    dist[x] = depth;
    for (auto el : ve[x]){
        if (el[0] != p){
            dfs(el[0], x, depth + 1);
        }
    }
}
int main(){
    int n, sp1, sp2, a, b;
    string col;
    cin>>n>>sp1>>sp2;
    sp1--, sp2--;
    dist.assign(n, 0);
    ve.resize(n);
    for (int i = 0; i < n - 1; i++){
        cin>>a>>b>>col;
        a--, b--;
        ve[a].push_back({b, 2});
        ve[b].push_back({a, 2});
    }
    dfs(sp1, sp1, 0);
    if (dist[sp2] % 2 == 1){
        cout<<"Marin";
    }
    else{
        cout<<"Paula";
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |