| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1284927 | quanlm | Experimental Charges (NOI19_charges) | C++20 | 15 ms | 1280 KiB | 
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define oo 1e18
#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii>
#define TASK "TEST"
int n, q;
int par[100005];
int acs(int u) {
    if (u == par[u]) return u;
    return par[u] = acs(par[u]);
}
void join(int u, int v) {
    int x = acs(u), y = acs(v);
    if (x != y) par[x] = y;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if (fopen(TASK".INP", "r")) {
        freopen(TASK".INP", "r", stdin);
        freopen(TASK".ANS", "w", stdout);
    }
    cin >> n >> q;
    for (int i = 1; i <= n; i++) par[i] = i;
    while (q--) {
        char type;
        cin >> type;
        if (type == 'A') {
            int a, b;
            cin >> a >> b;
        } else if (type == 'R') {
            int a, b;
            cin >> a >> b;
            join(a, b);
        } else {
            int a, b;
            cin >> a >> b;
            cout << (acs(a) == acs(b) ? 'R' : '?') << '\n';
        }
//        for (int i = 1; i <= n; i++) cout << e[i] << ' ';
//        cout << '\n';
    }
}
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... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
