# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
846381 | vjudge1 | KOVANICE (COI15_kovanice) | C++17 | 201 ms | 47628 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define int long long
using namespace std;
const int inf = 2e18 + 5;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
vector<int> par(N);
int find(int a){
if(a == par[a]) return a;
return par[a] = find(par[a]);
}
void merge(int a, int b){
a = find(a), b = find(b);
par[a] = b;
}
int32_t main(){
//freopen("in.txt","r", stdin);
int n, m, v;
cin>>n>>m>>v;
for(int i = 1; i <= m+5; i++) par[i] = i;
vector<array<int, 2> > type;
for(int i = 0; i < v; i++){
string s;
cin>>s;
if(s[1] == '='){
merge(s[0] - '0', s[2] - '0');
}
else{
type.pb({s[0] - '0', s[2] - '0'});
}
}
map<int, int> mp[2];
for(int i = 0; i < type.size(); i++){
int x = find(type[i][0]), y = find(type[i][1]);
mp[0][x] = 1;
mp[1][y] = 1;
}
for(int i = 1; i <= m; i++){
int x = find(i);
if(mp[0][x]) cout<<"K1"<<endl;
else if(mp[1][x])cout<<"K2"<<endl;
else cout<<"?"<<endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |