#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define DEBUG(b, s) cerr<<b<<s;
bool comp(pair<int, pair<char, int>> a, pair<int, pair<char, int>> b) {
if(a.s.f == '<')return true;
if(b.s.f == '<')return false;
return true;
}
int main () {
int n, m, q;
cin >> n >> m >> q;
vector<int> v(m, 300010);
vector<pair<int, pair<char, int>>> t;
while(q--) {
char c;
int a, b;
cin >> a >> c >> b;
t.push_back({a, {c, b}});
}
sort(t.begin(), t.end(), comp);
for(int i = 0;i<m;i++) {
int a = t[i].f, b = t[i].s.s;char c = t[i].s.f;
//DEBUG(c, '\n');
if(c == '=') {
if(v[a-1] <= 2)v[b-1] = v[a-1];
else v[a-1] = v[b-1];
}
else if(c == '<') {
v[a-1] = 1;
v[b-1] = 2;
}
}
for(int i = 0;i<m;i++) {
int a = t[i].f, b = t[i].s.s;char c = t[i].s.f;
//DEBUG(c, '\n');
if(c == '=') {
if(v[a-1] <= 2)v[b-1] = v[a-1];
else v[a-1] = v[b-1];
}
else if(c == '<') {
v[a-1] = 1;
v[b-1] = 2;
}
}
for(int i = 0;i<m;i++) {
if(v[i] > 2)cout<<"?\n";
else cout<<"K"<<v[i]<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
75 ms |
5788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
3708 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
226 ms |
13992 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |