제출 #1120406

#제출 시각아이디문제언어결과실행 시간메모리
1120406vjudge1KOVANICE (COI15_kovanice)C++17
50 / 100
104 ms15844 KiB
// author - alimammadzade #include <bits/stdc++.h> using namespace std; const int N = 3e5 + 3; vector<int> g[N]; bool vis[N]; int res[N], n, m, v, k1 = N - 2, k2 = N - 1, a, b; void dfs(int u, int k) { res[u] = k; vis[u] = 1; for (int v : g[u]) if (!vis[v]) dfs(v, k); } signed main() { cin.tie(nullptr)->sync_with_stdio(false); // system("cls"), freopen("in.txt", "r", stdin); cin >> n >> m >> v; while (v--) { char c; cin >> a >> c >> b; if (c == '=') { g[a].push_back(b); g[b].push_back(a); } else { g[k1].push_back(a); g[k2].push_back(b); } } dfs(k1, 1); dfs(k2, 2); for (int i = 1; i <= m; i++) if (res[i]) cout << 'K' << res[i] << '\n'; else cout << "?\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...