This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
struct query {
int a;
int b;
char c;
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, v;
cin >> n >> m >> v;
vector<int> types(m, -1);
vector<query> queries(v);
for (query &q : queries) {
cin >> q.a >> q.c >> q.b;
q.a--;
q.b--;
}
char changed;
do {
changed = false;
for (const query &q : queries) {
switch (q.c) {
case '<':
if (types[q.b] == -1 or types[q.a] == -1) {
types[q.b] = 2;
types[q.a] = 1;
changed = true;
}
break;
case '=':
if (types[q.b] != -1 and types[q.a] == -1) {
types[q.a] = types[q.b];
changed = true;
} else if (types[q.a] != -1 and types[q.b] == -1) {
types[q.b] = types[q.a];
changed = true;
}
break;
default:
break;
}
}
} while (changed);
for (const int &type : types) {
if (type == -1) {
cout << "?\n";
continue;
}
cout << 'K' << type << '\n';
}
return 0;
}
# | 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... |