| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1120583 | coolboy19521 | KOVANICE (COI15_kovanice) | C++17 | 503 ms | 524288 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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('<');
        assert(((pseq < S.size()) || (pslg < S.size())));
        if (pseq != -1) {
            int a = stoll(S.substr(0, pseq));
            int b = stoll(S.substr(pseq + 1, N - pseq - 1));
            dsu.Unite(a, b);
        } else {
            int a = stoll(S.substr(0, pslg));
            int b = stoll(S.substr(pslg + 1, N - pslg - 1));
            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;
            }
        }
    }
}
Compilation message (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... | ||||
