Submission #16595214


Source Code Expand

Copy
// Code for A - Disjoint Set Union
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

int main(){
	int N, q;

  cin >> N >> q;

	dsu d(N);

	while(q--){
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) {
      d.merge(u, v);
    } else {
      cout << d.same(u,v) << endl;
    }
	}
	return 0;
}

Submission Info

Submission Time
Task A - Disjoint Set Union
User sachaos
Language C++ (GCC 9.2.1 with AC Library)
Score 100
Code Size 341 Byte
Status AC
Exec Time 247 ms
Memory 3928 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 1
AC × 11
Set Name Test Cases
Sample example_00
All example_00, random_00, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09
Case Name Status Exec Time Memory
example_00 AC 9 ms 3456 KB
random_00 AC 195 ms 3820 KB
random_01 AC 194 ms 3816 KB
random_02 AC 156 ms 3620 KB
random_03 AC 40 ms 3612 KB
random_04 AC 129 ms 3672 KB
random_05 AC 175 ms 3508 KB
random_06 AC 148 ms 3928 KB
random_07 AC 36 ms 3512 KB
random_08 AC 75 ms 3532 KB
random_09 AC 247 ms 3672 KB