/*
ID: 5ak0
PROG:
LANG: C++11
*/
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7, MAXN = 3e5 + 10;
bool u[MAXN];
int mp[MAXN];
vector <int> g[MAXN];
int a, b;
char ch;
int n, m, v;
void dfs(int v){
u[v] = 1;
for (auto to : g[v]){
if (u[to] == 0){
mp[to] = mp[v];
dfs(to);
}
}
}
int main(){
cin >> n >> m >> v;
for (int i = 1; i <= v; ++i){
cin >> a >> ch >> b;
if (ch == '<'){
mp[a] = 1;
mp[b] = 2;
}
else{
g[a].pb(b);
g[b].pb(a);
}
}
for (int i = 1; i <= m; ++i)
if (u[i] == 0 && mp[i] != 0)
dfs(i);
for (int i = 1; i <= m; ++i){
if (mp[i] == 0)
cout << "?\n";
else{
cout << "K" << mp[i] << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
10516 KB |
Output is correct |
2 |
Correct |
0 ms |
10516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
128 ms |
12628 KB |
Output is correct |
2 |
Correct |
140 ms |
12364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
59 ms |
10648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
351 ms |
15004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |