This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
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;
}
# | 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... |