답안 #375200

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
375200 2021-03-09T04:24:50 Z vonatlus Magenta (COCI21_magenta) C++17
30 / 110
67 ms 8812 KB
/// vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 1e5+10;

vector<pii> adj[N];

int a, b, d[N];

void dfs(int x, int p = -1) {
    for (pii to : adj[x]) {
        if (to.x != p) {
            d[to.x] = d[x]+1;   
            dfs(to.x, x);
        }
    }
}

void ma1n() {
    int n;
    cin >> n >> a >> b;
    a--, b--;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        string s;
        cin >> s;
        int c = -1;
        if (s[0] == 'm') {
            c = 2;
        } else if (s[0] == 'r') {
            c = 0;
        } else {
            c = 1;
        }
        adj[u].pb({v, c});
        adj[v].pb({u, c});
    }
    dfs(a);
    cout << (d[b] & 1 ? "Marin" : "Paula"); 
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Incorrect 2 ms 2668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 8812 KB Output is correct
2 Correct 61 ms 8812 KB Output is correct
3 Correct 67 ms 8684 KB Output is correct
4 Correct 55 ms 8684 KB Output is correct
5 Correct 58 ms 8684 KB Output is correct
6 Correct 2 ms 2668 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Incorrect 2 ms 2668 KB Output isn't correct
4 Halted 0 ms 0 KB -