This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// author - alimammadzade
#include <bits/stdc++.h>
using namespace std;
const int M = 3e5 + 1;
vector<int> g[M];
bool vis[M];
int res[M], n, m, v, a, b, k1, k2;
void dfs(int u, int color) {
res[u] = color;
vis[u] = 1;
for (int v : g[u])
if (!vis[v])
dfs(v, color);
}
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 if (c == '<') {
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |