#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200100];
int ans[101][101][2];
void dfs(int n, int p, int t, int d) {
if(n==t)
cout << (d?"Marin":"Paula"),exit(0);
for(auto i: adj[n])
if(i-p)
dfs(i,n,t,!d);
}
int dfs2(int a, int b, int t) {
for(auto i: adj[a])
if(i!=3-t)
return ans[i][b][t];
for(auto i: adj[b])
if(i!=3-t)
return ans[a][i][t];
}
int main() {
cin.sync_with_stdio(false);
cin.tie(nullptr);
int n, a, b;
cin >> n >> a >> b;
for(int i = 1; i < n; i++) {
int x, y;
string str;
cin >> x >> y >> str;
adj[x].push_back(y);
adj[y].push_back(x);
}
dfs(a,0,b,0);
dfs2(a,b,0);
}
Compilation message
Main.cpp: In function 'int dfs2(int, int, int)':
Main.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Incorrect |
1 ms |
5164 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
9556 KB |
Output is correct |
2 |
Correct |
29 ms |
9652 KB |
Output is correct |
3 |
Correct |
38 ms |
9812 KB |
Output is correct |
4 |
Correct |
29 ms |
9672 KB |
Output is correct |
5 |
Correct |
29 ms |
9556 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Incorrect |
1 ms |
5164 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |