답안 #970949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970949 2024-04-27T15:32:22 Z Circling Kutije (COCI21_kutije) C++17
70 / 70
123 ms 9560 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int p[1001], s[1001];


int findp(int x){
    if (p[x] == x) return x;
    findp(p[x]);
    p[x] = p[p[x]];
    return p[x];
}


void unite(int a, int b){
    int pa = findp(a), pb = findp(b);
    if (pa == pb) return;
    if (s[pa] > s[pb]) swap(pa, pb);
    p[pa] = pb;
    s[pb] += s[pa];
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, q, k, l;
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++){
        p[i] = i;
        s[i] = 1;
    }
    while (m--){
        for (int i = 1; i <= n; i++){
            cin >> k;
            unite(i, k);
        }
    }
    while (q--){
        cin >> k >> l;
        cout << (findp(k) == findp(l) ? "DA\n" : "NE\n");
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 5700 KB Output is correct
2 Correct 54 ms 4948 KB Output is correct
3 Correct 52 ms 4692 KB Output is correct
4 Correct 64 ms 5716 KB Output is correct
5 Correct 65 ms 5640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 740 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 5700 KB Output is correct
2 Correct 54 ms 4948 KB Output is correct
3 Correct 52 ms 4692 KB Output is correct
4 Correct 64 ms 5716 KB Output is correct
5 Correct 65 ms 5640 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 740 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 110 ms 9556 KB Output is correct
27 Correct 119 ms 9556 KB Output is correct
28 Correct 92 ms 7964 KB Output is correct
29 Correct 106 ms 9052 KB Output is correct
30 Correct 103 ms 7988 KB Output is correct
31 Correct 95 ms 8016 KB Output is correct
32 Correct 123 ms 9528 KB Output is correct
33 Correct 116 ms 9532 KB Output is correct
34 Correct 112 ms 9560 KB Output is correct
35 Correct 114 ms 9556 KB Output is correct