Submission #588213

# Submission time Handle Problem Language Result Execution time Memory
588213 2022-07-02T19:28:01 Z MilosMilutinovic Magenta (COCI21_magenta) C++14
30 / 110
60 ms 9092 KB
/**
 *    author:  wxhtzdy
 *    created: 02.07.2022 21:03:17
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n;
  cin >> n;
  int a, b;
  cin >> a >> b;
  --a; --b;
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    string foo;
    cin >> foo;
    --u; --v;
    int t;
    if (foo == "plava") {
      t = 0;
    } else if (foo == "magenta") {
      t = 1;      
    } else {
      t = 2;
    }
    g[u].emplace_back(v, t);
    g[v].emplace_back(u, t);
  }
  vector<int> dep(n);
  vector<int> par(n);
  function<void(int, int)> Dfs = [&](int v, int pr) {
    par[v] = pr;
    dep[v] = dep[pr] + 1;
    for (auto& e : g[v]) {
      int u = e.first;
      if (u == pr) {
        continue;
      }
      Dfs(u, v);
    }
  };
  Dfs(0, 0);
  int x = a, y = b, dis = 0;
  while (x != y) {
    if (dep[x] > dep[y]) {
      x = par[x];
    } else {
      y = par[y];
    }
    dis += 1;
  }
  cout << (dis % 2 == 1 ? "Marin" : "Paula") << '\n';                                                        
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 8988 KB Output is correct
2 Correct 59 ms 8984 KB Output is correct
3 Correct 60 ms 9092 KB Output is correct
4 Correct 50 ms 9048 KB Output is correct
5 Correct 49 ms 9092 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -