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 v1.1)
Score 100
Code Size 341 Byte
Status
Exec Time 247 ms
Memory 3928 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_00
All 100 / 100 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 9 ms 3456 KB
random_00 195 ms 3820 KB
random_01 194 ms 3816 KB
random_02 156 ms 3620 KB
random_03 40 ms 3612 KB
random_04 129 ms 3672 KB
random_05 175 ms 3508 KB
random_06 148 ms 3928 KB
random_07 36 ms 3512 KB
random_08 75 ms 3532 KB
random_09 247 ms 3672 KB