답안 #573713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
573713 2022-06-07T05:47:30 Z Devigo Experimental Charges (NOI19_charges) C++14
14 / 100
204 ms 156976 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
 
const int w = 1000050;
int n, m;
char c;
vector<int> parent((int) 1e7), siz((int) 1e7, 1);
 
int findpar(int x) {
    if(x == parent[x]) return x;
    return parent[x] = findpar(parent[x]);
}
 
void unite(int x, int y) {
    x = findpar(x);
    y = findpar(y);
 
    if(x == y) return;
    if(siz[y] > siz[x]) swap(x, y);
 
    parent[y] = x;
    siz[x] += siz[y];
}
 
signed main() {
    cin >> n >> m;
    for(int i = 0; i < (int) 1e7; ++i) parent[i] = i;
 
    int x, y;
    while(m--) {
        cin >> c; cin >> x >> y;
        if(c == 'A') {
            unite(x, y + w);
            unite(x + w, y);
        } else if(c == 'R') {
            unite(x, y);
            unite(x + w, y + w);
        } else {
            int p, q, r;
            p = findpar(x);
            q = findpar(y);
            r = findpar(x + w);
            //s = findpar(y + w);
 
            //if(p == q && p == s) cout << "?";
            if (p == q) cout << "R";
            else if (p == r) cout << "A";
            else cout << "?";
            cout << "\n";
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 156748 KB Output is correct
2 Incorrect 67 ms 156824 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 163 ms 156876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 156924 KB Output is correct
2 Correct 200 ms 156952 KB Output is correct
3 Correct 204 ms 156976 KB Output is correct
4 Correct 172 ms 156908 KB Output is correct
5 Correct 183 ms 156948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 185 ms 156868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 156748 KB Output is correct
2 Incorrect 67 ms 156824 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 156748 KB Output is correct
2 Incorrect 67 ms 156824 KB Output isn't correct
3 Halted 0 ms 0 KB -