답안 #373269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373269 2021-03-04T01:27:43 Z rk42745417 Magenta (COCI21_magenta) C++17
30 / 110
61 ms 7788 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;
		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';
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 -