Submission #373268

# Submission time Handle Problem Language Result Execution time Memory
373268 2021-03-04T01:24:06 Z rk42745417 Magenta (COCI21_magenta) C++17
0 / 110
386 ms 524292 KB
#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;
		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 Runtime error 351 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 386 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 351 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -