이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"bits/stdc++.h"
using namespace std;
const int mxN = 300005;
struct Dsu {
    int ar[mxN];
    Dsu() {
        fill(ar, ar + mxN, -1);
    }
    int Find(int u) {
        if (0 > ar[u]) {
            return u;
        } else {
            return ar[u] = Find(ar[u]);
        }
    }
    void Unite(int u, int v) {
        u = Find(u);
        v = Find(v);
        if (ar[u] > ar[v]) {
            swap(u, v);
        }
        ar[u] += ar[v];
        ar[v] = u;
    }
} dsu;
main() {
    int N, M, V;
    cin >> N >> M >> V;
    int l = -1;
    int g = -1;
    for (int i = 0; i < V; i ++) {
        string S;
        cin >> S;
        int N = S.size();
        int pseq = S.find('=');
        int pslg = S.find('<');
        if (pseq != -1) {
            int a = stoll(S.substr(0, pseq));
            int b = stoll(S.substr(pseq + 1, N - pseq));
            dsu.Unite(a, b);
        } else {
            int a = stoll(S.substr(0, pslg));
            int b = stoll(S.substr(pslg + 1, N - pslg));
            l = a, g = b;
        }
    }
    if (-1 == l && -1 == g) {
        for (int i = 0; i < M; i ++) {
            cout << '?' << endl;
        }
    } else {
        for (int i = 1; i <= M; i ++) {
            if (dsu.Find(i) == dsu.Find(l)) {
                cout << "K1" << endl;
            } else if (dsu.Find(i) == dsu.Find(g)) {
                cout << "K2" << endl;
            } else {
                cout << '?' << endl;
            }
        }
    }
}
컴파일 시 표준 에러 (stderr) 메시지
kovanice.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main() {
      | ^~~~| # | 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... |