Submission #1120365

#TimeUsernameProblemLanguageResultExecution timeMemory
1120365vjudge1KOVANICE (COI15_kovanice)C++17
0 / 100
52 ms10756 KiB
// author - alimammadzade #include <bits/stdc++.h> using namespace std; const int N = 3e5 + 1; vector<int> g[N]; bool vis[N]; int res[N], n, m, v, k1, k2, 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; if (n == 2) { while (v--) { char c; cin >> a >> c >> b; if (c == '=') { g[a].push_back(b); g[b].push_back(a); } else { k1 = a; k2 = b; } } if (k1) dfs(k1, 1); if (k2) 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...