#include <bits/stdc++.h>
using namespace std;
#define SPEED \
ios_base::sync_with_stdio(0); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb push_back
#define endl "\n"
#define ALL(x) x.begin(), x.end()
#define intt long long
const intt mxN = 2e5 + 5;
vector<vector<intt>>graph;
vector<bool>visited(mxN, 0);
vector<string>anss(mxN);
void dfs(intt node, string s) {
visited[node] = 1;
anss[node] = s;
for(auto u : graph[node]) {
if(!visited[u]){
dfs(u, s);
}
}
}
void solve() {
int n, m, v;
cin >> n >> m >> v;
map<char,intt> mp[m + 1];
graph.resize(m + 1);
anss.resize(m + 1);
for(int i = 1; i <= m; i++) {
anss[i] = "?";
}
map<intt,intt>k1, k2;
vector<string>beraber;
while(v--) {
int a, c; char b;
cin >> a >> b >> c;
if(b == '=') {
graph[a].pb(c);
graph[c].pb(a);
} else if(b == '<') {
anss[a] = "K1";
anss[c] = "K2";
k1[a]++;
k2[c]++;
} else {
anss[c] = "K1";
anss[a] = "K2";
k2[a]++;
k1[c]++;
}
}
for(int i = 1; i <= m; i++) {
if(k1[i] > 0) {
dfs(i, "K1");
} else if(k2[i] > 0) {
dfs(i, "K2");
}
}
for(int i = 1; i <= m; i++) {
cout << anss[i] << endl;
}
}
int main(){
SPEED;
int tst = 1, i = 1;
// cin >> tst;
while(tst--) {
solve();
}
return 0;
}
Compilation message
kovanice.cpp: In function 'int main()':
kovanice.cpp:77:18: warning: unused variable 'i' [-Wunused-variable]
77 | int tst = 1, i = 1;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
6736 KB |
Output is correct |
2 |
Correct |
8 ms |
6736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
234 ms |
46284 KB |
Output is correct |
2 |
Correct |
217 ms |
45128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
29 ms |
7700 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
651 ms |
124132 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |