buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
import sys
input = sys.stdin.readline
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
... | import sys
input = sys.stdin.readline
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
... | [["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 279 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < ll(b); i++)
#define repr(i, a, b) for (ll i = a; i >= ll(b); i--)
#define endl "\n"
#define ALL(x) x.begin(), x.end()
#define AL... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < ll(b); i++)
#define repr(i, a, b) for (ll i = a; i >= ll(b); i--)
#define endl "\n"
#define ALL(x) x.begin(), x.end()
#define AL... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 261 |
#if loc || local
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < ll(n); ++i)
#define repr(i, n) for (ll i = ll(n); i-- > 0;)
using ll = int_fast64_t;
using pll = pair<ll, ll>;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;
template <class T> ... | #if loc || local
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < ll(n); ++i)
#define repr(i, n) for (ll i = ll(n); i-- > 0;)
using ll = int_fast64_t;
using pll = pair<ll, ll>;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;
template <class T> ... | [["+", 51, 218, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 51, 218, 8, 9, 0, 37, 0, 16, 12, 13]] | 1 | 668 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from... | [["-", 698, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 698, 14, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 652 |
//インクルード(アルファベット順)
#include <algorithm> //sort,二分探索,など
#include <bitset> //固定長bit集合
#include <chrono> //実行時間計測
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー
#include <functional> //sortのgreater
#include <iomanip> //setprecision(浮動小数点の出力の誤差)
#include <iostre... | //インクルード(アルファベット順)
#include <algorithm> //sort,二分探索,など
#include <bitset> //固定長bit集合
#include <chrono> //実行時間計測
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー
#include <functional> //sortのgreater
#include <iomanip> //setprecision(浮動小数点の出力の誤差)
#include <iostre... | [["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]] | 1 | 1,018 |
n,m = map(int,input().split())
f = [[] for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
a -= 1
b -= 1
f[a].append(b)
f[b].append(a)
import collections
q = collections.deque()
for i in range(n):
for j in f[i]:
q.append(j)
while q:
p = q... | n,m = map(int,input().split())
f = [[] for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
a -= 1
b -= 1
f[a].append(b)
f[b].append(a)
import collections
q = collections.deque()
for i in range(n):
for j in f[i]:
q.append(j)
while q:
p = q... | [["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]] | 5 | 194 |
// Code for D - Friends
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, x, y) for (ll i = x; i < (ll)(y); i++)
#define MOD 1000000007
#define mod(x) ((x) % MOD + MOD) % MOD
#define debug(var) ... | // Code for D - Friends
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, x, y) for (ll i = x; i < (ll)(y); i++)
#define MOD 1000000007
#define mod(x) ((x) % MOD + MOD) % MOD
#define debug(var) ... | [["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]] | 1 | 563 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int a[maxn];
int find(int x) {
if (a[x] == x)
return x;
else
return a[x] = find(a[x]);
}
int main() {
int n, m, aa, bb;
cin >> n >> m;
for (int i = 1; i <= n; i++)
a[i] = i;
for (int i = 1; i <= m; i++) ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int a[maxn];
int find(int x) {
if (a[x] == x)
return x;
else
return a[x] = find(a[x]);
}
int main() {
int n, m, aa, bb;
cin >> n >> m;
for (int i = 1; i <= n; i++)
a[i] = i;
for (int i = 1; i <= m; i++) ... | [["+", 0, 11, 31, 69, 341, 342, 0, 2, 63, 22], ["+", 31, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["+", 31, 69, 341, 342, 0, 2, 3, 4, 0, 25]] | 1 | 205 |
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5;
const int MaxM = 2e5;
int cnt[MaxN + 1];
int who[MaxN + 1];
inline int FindRoot(int x) {
if (who[x] != x)
who[x] = FindRoot(who[x]);
return who[x];
}
int main() {
int N, M;
int A, B, who_A, who_B;
scanf("%d %d\n", &N, &M);
for (int ... | #include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5;
const int MaxM = 2e5;
int cnt[MaxN + 1];
int who[MaxN + 1];
inline int FindRoot(int x) {
if (who[x] != x)
who[x] = FindRoot(who[x]);
return who[x];
}
int main() {
int N, M;
int A, B, who_A, who_B;
scanf("%d %d\n", &N, &M);
for (int ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 241 |
sys.setrecursionlimit(10000)
class Graph:
def __init__(self,n,side):
self.side = side
self.neighbor = [set() for i in range(n+1)]
self.visited = [False]*(n+1)
self.group =[0]*n
self.product()
def product(self):
for a,b in self.side:
self.neighbor[a].a... | import sys
sys.setrecursionlimit(10000000)
class Graph:
def __init__(self,n,side):
self.side = side
self.neighbor = [set() for i in range(n+1)]
self.visited = [False]*(n+1)
self.group =[0]*n
self.product()
def product(self):
for a,b in self.side:
self... | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22]] | 5 | 264 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define end... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define end... | [["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 1 | 267 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 966 |
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include <algorithm> //sort,二分探索,など
#include <bits/stdc++.h>
#include <bitset> //固定長bit集合
#include <chrono> //実行時間計測
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー... | //コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include <algorithm> //sort,二分探索,など
#include <bits/stdc++.h>
#include <bitset> //固定長bit集合
#include <chrono> //実行時間計測
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー... | [["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 578 |
#include <bits/stdc++.h>
// @author : sam000013
#define int long long
#define PI 3.14159265
#define pb(x) push_back(x)
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout << "\n"
#define dbg(x) \
cout << #x << " " << x; ... | #include <bits/stdc++.h>
// @author : sam000013
#define int long long
#define PI 3.14159265
#define pb(x) push_back(x)
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout << "\n"
#define dbg(x) \
cout << #x << " " << x; ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 338 |
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <time.h>
#include <vector>
#define h 200010
#define lli long long int
#define pb push_back
#define pof pop_front
#define lb lower_bo... | #include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <time.h>
#include <vector>
#define h 200010
#define lli long long int
#define pb push_back
#define pof pop_front
#define lb lower_bo... | [["+", 8, 9, 0, 57, 75, 76, 0, 37, 0, 38]] | 1 | 339 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct UnionFind {
vector<int> par, gsize;
int sz;
UnionFind(int N) : par(N), gsize(N), sz(N) {
for (int i = 0; i < N; i++) {
par[i] = i;
gsize[i] = 1;
}
}
// root:子xの根を返す
int root(int x) {
if (par[x] == x)
r... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
struct UnionFind {
vector<int> par, gsize;
int sz;
UnionFind(int N) : par(N), gsize(N), sz(N) {
for (int i = 0; i < N; i++) {
par[i] = i;
gsize[i] = 1;
}
}
// root:子xの根を返す
int root(int x) {
if (par[x] == x)
r... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 346 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pair2;
typedef std::pair<int, pair2> pair3;
const ll INF = 1LL << 60;
int main() {
ll N, M;
cin >> N >> M;
ll A[M], B[M];
vector<vector<ll>> fri(N + 1, vector<ll>(0, 0));
for (ll i = 0; i < M; i++) {
cin >> A... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pair2;
typedef std::pair<int, pair2> pair3;
const ll INF = 1LL << 60;
int main() {
ll N, M;
cin >> N >> M;
ll A[M], B[M];
vector<vector<ll>> fri(N + 1, vector<ll>(0, 0));
for (ll i = 0; i < M; i++) {
cin >> A... | [["+", 49, 50, 51, 4, 0, 16, 31, 16, 31, 13], ["+", 49, 50, 51, 4, 0, 16, 31, 16, 17, 48], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 431 |
#include <bits/stdc++.h>
using namespace std;
vector<int> djs(200001, -1);
int root(int a) { return djs[a] < 0 ? a : djs[a] = root(djs[a]); }
int unite(int a, int b) {
int root_a = root(a);
int root_b = root(b);
if (root_a == root_b)
return 0;
if (djs[root_a] > djs[root_b])
swap(root_a, root_b);
dj... | #include <bits/stdc++.h>
using namespace std;
vector<int> djs(200001, -1);
int root(int a) { return djs[a] < 0 ? a : djs[a] = root(djs[a]); }
int unite(int a, int b) {
int root_a = root(a);
int root_b = root(b);
if (root_a == root_b)
return 0;
if (djs[root_a] > djs[root_b])
swap(root_a, root_b);
dj... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 196 |
def main():
n, m = map(int, input().split())
g = [[] for i in [0]*(n+1)]
for _ in range(m):
a, b = map(int, input().split())
g[a].append(b)
g[b].append(a)
def bfs(n, m, adj):
visited = [0 for i in [0]*(n+1)]
ans = 1
for i in range(n+1):
if vis... | from collections import deque
def main():
n, m = map(int, input().split())
g = [[] for i in [0]*(n+1)]
for _ in range(m):
a, b = map(int, input().split())
g[a].append(b)
g[b].append(a)
def bfs(n, m, adj):
visited = [0 for i in [0]*(n+1)]
ans = 1
for i in... | [["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]] | 5 | 218 |
class UnionFind:
def __init__(self):
self.parents = {}
self.sz = {}
self.size = 0
def add(self, a):
if a in self.parents:
return
self.size += 1
self.sz[a] = 1
self.parents[a] = a
def find(self, a):
if self.parents[a] != a:
... | class UnionFind:
def __init__(self):
self.parents = {}
self.sz = {}
self.size = 0
def add(self, a):
if a in self.parents:
return
self.size += 1
self.sz[a] = 1
self.parents[a] = a
def find(self, a):
if self.parents[a] != a:
... | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]] | 5 | 320 |
from collections import deque
n, m = map(int, input().split())
friends = [[]*n for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
friends[a].append(b)
friends[b].append(a)
id_list = [-1]*n
def dfs(friends, start):
d = deque()
group_count = 0
if id_li... | from collections import deque
n, m = map(int, input().split())
friends = [[]*n for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
friends[a].append(b)
friends[b].append(a)
id_list = [-1]*n
def dfs(friends, start):
d = deque()
group_count = 0
if id_li... | [["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 198 |
n,m = map(int,input().split())
dic = {}
for i in range(n):
dic[i+1]=set()
for _ in range(m):
a,b = map(int,input().split())
dic[a].add(b)
dic[b].add(a)
max_num = 0
registerd_set = set()
for i in range(1,n+1):
if i in registerd_set:
continue
else:
people_list = [i]
r... | n,m = map(int,input().split())
dic = {}
for i in range(n):
dic[i+1]=set()
for _ in range(m):
a,b = map(int,input().split())
dic[a].add(b)
dic[b].add(a)
max_num = 0
registerd_set = set()
for i in range(1,n+1):
if i in registerd_set:
continue
else:
people_list = [i]
r... | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 168 |
/*
* @author: codancer
* @createTime: 2020-08-30, 22:48:51
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <rando... | /*
* @author: codancer
* @createTime: 2020-08-30, 22:48:51
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <rando... | [["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]] | 1 | 377 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(0);
const double EPS = 1e-9;
const double PI = acos(-1);
const int knightDir[8... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(0);
const double EPS = 1e-9;
const double PI = acos(-1);
const int knightDir[8... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 394 |
N,M,*P = $<.read.split.map &:to_i
A = [[]]*(N+1)
m = 0
M.times {|i|
r,a = [],P[i+i,2]
x,y = a.map {|i;j| (r<< i; i=j) while (j=A[i])[0]; r<< i; i}.sort
g,h = [A[x],A[y]].map{|h| h.empty? ? a.to_h{[_1,0]} : h}.sort_by{_1.size}
h.merge! g if h.object_id != g.object_id
r.each {A[_1] = y}
A[y] = h
m < h.size... | N,M,*P = $<.read.split.map &:to_i
A = [[]]*(N+1)
m = 1
M.times {|i|
r,a = [],P[i+i,2]
x,y = a.map {|i;j| (r<< i; i=j) while (j=A[i])[0]; r<< i; i}.sort
g,h = [A[x],A[y]].map{|h| h.empty? ? a.to_h{[_1,0]} : h}.sort_by{_1.size}
h.merge! g if h.object_id != g.object_id
r.each {A[_1] = y}
A[y] = h
m < h.size... | [["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612]] | 4 | 184 |
N,M,*P = $<.read.split.map &:to_i
C = [1]*(N+1)
A = C.map {[]}
m = 0
(0...M).map {|i| a=P[i+=i]; b=P[i+1]; a<b ? [a,b] : [b,a]}.sort.each{|a,b| A[a] << b}
1.upto(N) {|i|
a = A[j=i]
a.each {k = A[_1][-1]||_1; j<k && j=k}
next if j == i
a.each {b=A[_1]; b << j if b[-1]!=j}
m < C[j]+=C[i] and m = C[j]
}
p m | N,M,*P = $<.read.split.map &:to_i
C = [m=1]*(N+1)
A = C.map {[]}
(0...M).map {|i| a=P[i+=i]; b=P[i+1]; a<b ? [a,b] : [b,a]}.sort.each{|a,b| A[a] << b}
1.upto(N) {|i|
a = A[j=i]
a.each {k = A[_1][-1]||_1; j<k && j=k}
next if j == i
a.each {b=A[_1]; b << j if b[-1]!=j}
m < C[j]+=C[i] and m = C[j]
}
p m | [["+", 0, 662, 12, 738, 31, 516, 0, 662, 31, 22], ["+", 0, 662, 12, 738, 31, 516, 0, 662, 0, 32], ["-", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["-", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612]] | 4 | 193 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | [["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 419 |
#include <bits/stdc++.h>
using namespace std;
#define FastRead \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define endl "\n"
#define sq(x) ((x) * (x))
#define pi acos(-1.0)
#define NUM 200005
typedef ... | #include <bits/stdc++.h>
using namespace std;
#define FastRead \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define endl "\n"
#define sq(x) ((x) * (x))
#define pi acos(-1.0)
#define NUM 200005
typedef ... | [["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 57, 64, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 57, 64, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]... | 1 | 283 |
import java.util.Scanner;
class UnionFind {
// The number of elements in this union find
private int size;
// Used to track the size of each of the component
private int[] sz;
// id[i] points to the parent of i, if id[i] = i then i is a root node
private int[] id;
// Tracks the number of components i... | import java.util.Scanner;
class UnionFind {
// The number of elements in this union find
private int size;
// Used to track the size of each of the component
private int[] sz;
// id[i] points to the parent of i, if id[i] = i then i is a root node
private int[] id;
// Tracks the number of components i... | [["+", 49, 200, 51, 230, 3, 4, 0, 16, 17, 72], ["+", 49, 200, 51, 230, 3, 4, 0, 16, 12, 499]] | 3 | 531 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x ... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x ... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 48], ["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 23, 0, 664, 17, 33], ["+", 3, 4, 0, 657, 12, 23, 0, 664, 28, 612], ["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 25]] | 5 | 436 |
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
#define ff first
#define ss second
#define int long long
#define boost \
ios::sync_with_stdio(false); \
cin.tie(nullptr)
#define en... | #include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
#define ff first
#define ss second
#define int long long
#define boost \
ios::sync_with_stdio(false); \
cin.tie(nullptr)
#define en... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 312 |
N, M = map(int, input().split())
friends = {i: set([]) for i in range(N)}
for i in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
friends[a].add(b)
friends[b].add(a)
#print(friends)
from collections import deque
reached = [-1] * N
ans = 1
for i in range(N):
if reached[i] == -1:
... | N, M = map(int, input().split())
friends = {i: set([]) for i in range(N)}
for i in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
friends[a].add(b)
friends[b].add(a)
#print(friends)
from collections import deque
reached = [-1] * N
ans = 1
for i in range(N):
if reached[i] == -1:
... | [["+", 64, 196, 0, 52, 15, 666, 0, 652, 63, 22], ["+", 0, 52, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 52, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 0, 57, 64, 196, 0, 52, 15, 666, 667, 47], ["+", 0, 57, 64, 196, 0, 52, 15, 666, 0, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 191 |
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, l, r) for (ll i = l; i < (ll)(r); i++)
#define max(l, r) ((l) > (r) ? l : r)
#define min(l, r) ((l) < (r) ? l : r)
#define swap(l, r... | #include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, l, r) for (ll i = l; i < (ll)(r); i++)
#define max(l, r) ((l) > (r) ? l : r)
#define min(l, r) ((l) < (r) ? l : r)
#define swap(l, r... | [["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]] | 0 | 377 |
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;
// ============union_find_tree===============
ll MAX_N = 200010;
vector<ll> par(MAX_N); // MAX_N == num of node
vector<ll> tree_rank(MAX_N);
void init(ll n) {
for (ll i = 0; i < n; ++i) {
par.at(i) = i;
tree_r... | #include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;
// ============union_find_tree===============
ll MAX_N = 200010;
vector<ll> par(MAX_N); // MAX_N == num of node
vector<ll> tree_rank(MAX_N);
void init(ll n) {
for (ll i = 0; i < n; ++i) {
par.at(i) = i;
tree_r... | [["-", 31, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["-", 31, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["-", 31, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 11, 31, 2, 3, 4, 0, 2, 63, 22]] | 1 | 411 |
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠺⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⠀⠈⢿⣦⣄⣈⣁⣀⣠⣴⣦⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⣶⡄⠙⢿⣿⣿⣿⣿⣿⡿⠓⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠙⣿⣿⠿⠛⠛⠛⠛⣿⣿⡄⠀⠈⠉⠉⠉⣁⣀⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⣸⣿⡇⠀⠀⠀⣴⣿⣿⡿⠿⢷⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠠⣤⣤⣴⣾⣿⡿⠁⠀⢀⣾⣿⣿⠏⠀⠀⠈⣿⣧⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣏⠀⠀⣠⣾⣿⣿⠏⠀⠀⠀⠀⢹⣿⡄⠀⠀
⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠻⣿⣿⡟⠻⠿⠛⠁⠀⠀⠀⠀⠀⣾⣿⡇⠀⠀
⠀⠀... | /*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠺⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⠀⠈⢿⣦⣄⣈⣁⣀⣠⣴⣦⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⣶⡄⠙⢿⣿⣿⣿⣿⣿⡿⠓⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠙⣿⣿⠿⠛⠛⠛⠛⣿⣿⡄⠀⠈⠉⠉⠉⣁⣀⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⣸⣿⡇⠀⠀⠀⣴⣿⣿⡿⠿⢷⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠠⣤⣤⣴⣾⣿⡿⠁⠀⢀⣾⣿⣿⠏⠀⠀⠈⣿⣧⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣏⠀⠀⣠⣾⣿⣿⠏⠀⠀⠀⠀⢹⣿⡄⠀⠀
⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠻⣿⣿⡟⠻⠿⠛⠁⠀⠀⠀⠀⠀⣾⣿⡇⠀⠀
⠀⠀... | [["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 21], ["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 147], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]] | 1 | 389 |
class UnionFind:
def __init__(self, n):
self.parent = [-1] * n
self.rank = [-1] * n
self.count = [-1] * n
def get_root(self, i):
while self.parent[i] != -1:
i = self.parent[i]
return i
def is_same_tree(self, i, j):
return self.get_root(i) == self.get_root(j)
def merge(self, i, j... | class UnionFind:
def __init__(self, n):
self.parent = [-1] * n
self.rank = [1] * n
self.count = [1] * n
def get_root(self, i):
while self.parent[i] != -1:
i = self.parent[i]
return i
def is_same_tree(self, i, j):
return self.get_root(i) == self... | [["-", 0, 662, 12, 657, 31, 634, 0, 664, 17, 33]] | 5 | 304 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
vector<ll> ad[200006];
vector<ll> vis(200006, 0);
ll ans = 0, n, m, k;
void add(ll x, ll y) {
ad[x].push_back(y);
ad[y].push_back(x);
}
ll dfs(ll node) {
vis[node] = 1;
++ans;
for (ll i : ad[node]) {
if (!vis[i])
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
vector<ll> ad[200006];
vector<ll> vis(200006, 0);
ll ans = 0, n, m, k;
void add(ll x, ll y) {
ad[x].push_back(y);
ad[y].push_back(x);
}
ll dfs(ll node) {
vis[node] = 1;
++ans;
for (ll i : ad[node]) {
if (!vis[i])
... | [["-", 64, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 231 |
#include <cstdio>
#include <iostream>
using namespace std;
int n, m, f[300006], a, b, ans = 0, max1[300006], s;
int find(int x) { return x == f[x] ? x : (f[x] = find(f[x])); }
void merge(int i, int j) {
s = find(i);
f[find(i)] = find(j);
max1[f[j]] += max1[s];
if (ans < max1[f[j]])
ans = max1[f[j]];
}
int m... | #include <cstdio>
#include <iostream>
using namespace std;
int n, m, f[300006], a, b, ans = 1, max1[300006], s;
int find(int x) { return x == f[x] ? x : (f[x] = find(f[x])); }
void merge(int i, int j) {
s = find(i);
f[find(i)] = find(j);
max1[f[j]] += max1[s];
if (ans < max1[f[j]])
ans = max1[f[j]];
}
int m... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]] | 1 | 241 |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct UnionFind {
vector<int> r; // represents parent/size*(-1) at child/root
UnionFind(int n) { r = vector<int>(n, -1); }
int root(int n) {
if (r[n] <= 0)
return n;
else
return r[n] = root(r[n]);
}
void u... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct UnionFind {
vector<int> r; // represents parent/size*(-1) at child/root
UnionFind(int n) { r = vector<int>(n, -1); }
int root(int n) {
if (r[n] < 0)
return n;
else
return r[n] = root(r[n]);
}
void un... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 271 |
N, M = map(int, input().split())
path = [set() for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
path[a-1].add(b-1)
path[b-1].add(a-1)
visited = [0] * N
ans = 1
for u in range(N):
if visited[u] == 1:
continue
curr = 1
next_u = path[u]
while next_u:
v = n... | N, M = map(int, input().split())
path = [set() for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
path[a-1].add(b-1)
path[b-1].add(a-1)
visited = [0] * N
ans = 1
for u in range(N):
if visited[u] == 1:
continue
curr = 1
visited[u] = 1
next_u = path[u]
while ne... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 178 |
from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
dist = [-1] * (n+1)
dist[0] = 0
d = deque()
ans = 0
for j in range(len(dist)):
if dist[j] != -1:
continu... | from collections import deque
n, m = map(int, input().split())
#graph = [[] for _ in range(n+1)]
graph = [set() for _ in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
# graph[a].append(b)
# graph[b].append(a)
graph[a].add(b)
graph[b].add(a)
dist = [-1] * (n+1)
dist[0] = 0
d =... | [["-", 0, 1, 0, 662, 12, 658, 8, 634, 0, 70], ["-", 0, 1, 0, 662, 12, 658, 8, 634, 0, 73], ["+", 0, 1, 0, 662, 12, 658, 8, 652, 63, 22], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22],... | 5 | 195 |
from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
dist = [-1] * (n+1)
dist[0] = 0
d = deque()
ans = 0
for j in range(len(dist)):
if dist[j] != -1:
continu... | from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
dist = [-1] * (n+1)
dist[0] = 0
d = deque()
ans = 1
for j in range(len(dist)):
if dist[j] != -1:
continu... | [["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]] | 5 | 195 |
'''
We can show that if u and v belong to the same connected component, then they are friends w/ each other
So everyone in a given connected component is friends with one another
So everyone in a given connected component must be separated into different groups
If we have a CC of with sz nodes in i... | '''
We can show that if u and v belong to the same connected component, then they are friends w/ each other
So everyone in a given connected component is friends with one another
So everyone in a given connected component must be separated into different groups
If we have a CC of with sz nodes in it, then we need ... | [["-", 36, 36, 0, 656, 0, 1, 0, 557, 0, 6], ["+", 36, 36, 0, 656, 0, 1, 0, 557, 0, 6]] | 5 | 180 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int f[N + 10];
int sz[N + 10];
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
int merge(int u, int v) {
int uf = find(u);
int vf = find(v);
if (uf != vf) {
sz[uf] += sz[vf];
sz[vf] = 0;
f[vf] = uf;
}
return sz[uf];
}
i... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int f[N + 10];
int sz[N + 10];
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
int merge(int u, int v) {
int uf = find(u);
int vf = find(v);
if (uf != vf) {
sz[uf] += sz[vf];
sz[vf] = 0;
f[vf] = uf;
}
return sz[uf];
}
i... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 210 |
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
n,m = map(int, input().split())
par = [i for i in range(n)]
rank = [0]*n
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
... | import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
n,m = map(int, input().split())
par = [i for i in range(n)]
rank = [0]*n
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
... | [["+", 0, 1, 0, 677, 31, 206, 206, 652, 63, 22], ["+", 0, 677, 31, 206, 206, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 677, 31, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 677, 31, 206, 206, 657, 12, 612], ["+", 0, 677, 31, 206, 206, 652, 3, 4, 0, 25]] | 5 | 244 |
class UnionFind:
def __init__(self, n):
self.par = [0] * n
self.chi = [0] * n
for i in range(n):
self.par[i] = i
self.chi[i] = 1
self.max_child = 0
def root(self, x):
if self.par[x] == x:
return x
rx = self.root(self.par[x])
... | class UnionFind:
def __init__(self, n):
self.par = [0] * n
self.chi = [0] * n
for i in range(n):
self.par[i] = i
self.chi[i] = 1
self.max_child = 1
def root(self, x):
if self.par[x] == x:
return x
rx = self.root(self.par[x])
... | [["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 286 |
#include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define pi 3.141592653
#define in freopen("entrada",... | #include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define pi 3.141592653
#define in freopen("entrada",... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 43, 0, 42, 0, 47], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]] | 1 | 343 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x ... | [["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 652, 3, 4, 0, 657, 31, 206, 206, 612], ["+", 0, 652, 3, 4, 0, 657, 31, 206, 206, 612], ["-", 12, 652, 3, 4, 0, 657, 31, 206, 206, 612], ["+", 12, 652, 3, 4, 0, 657, 31, 206, 206, 612]] | 5 | 448 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int MAX(2e5 + 2);
#define debug2(x, y) cout << x << " " << y << "\n"
ll const mod = 1e9 + 7;
vector<int> visited(MAX, 0);
vector<vector<int>> adj(MAX);
int main() {
int n, m, x, y, ans = 0;
cin >> n >> m;
for (int i ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int MAX(2e5 + 2);
#define debug2(x, y) cout << x << " " << y << "\n"
ll const mod = 1e9 + 7;
vector<int> visited(MAX, 0);
vector<vector<int>> adj(MAX);
int main() {
int n, m, x, y, ans = 0;
cin >> n >> m;
for (int i ... | [["-", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22], ["+", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22]] | 1 | 267 |
#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005], f[200005], t[200005];
int find_(int x) {
if (f[x] != x)
f[x] = find_(f[x]);
return f[x];
}
bool cmp(int x, int y) { return x > y; }
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
f[i] = i;
for (int i = 1; i <... | #include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005], f[200005], t[200005];
int find_(int x) {
if (f[x] != x)
f[x] = find_(f[x]);
return f[x];
}
bool cmp(int x, int y) { return x > y; }
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
f[i] = i;
for (int i = 1; i <... | [["-", 0, 27, 28, 69, 341, 342, 0, 69, 28, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 25]] | 1 | 237 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int n, m;
int fa[N], sum[N];
int find(int x) {
if (fa[x] != x)
fa[x] = find(fa[x]);
return fa[x];
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++)
fa[i] = i;
for (int i = 1; i <= m; i++) {
int x, y;
cin >> x >> y;
... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int n, m;
int fa[N], sum[N];
int find(int x) {
if (fa[x] != x)
fa[x] = find(fa[x]);
return fa[x];
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++)
fa[i] = i;
for (int i = 1; i <= m; i++) {
int x, y;
cin >> x >> y;
... | [["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]] | 1 | 201 |
#include <bits/stdc++.h>
#define rep(i, f, n) for (int i = (f); (i) < (n); i++)
#define repe(i, f, n) for (int i = (f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout << #x << " :: " << x << "\n";
#define debug2(x, y) ... | #include <bits/stdc++.h>
#define rep(i, f, n) for (int i = (f); (i) < (n); i++)
#define repe(i, f, n) for (int i = (f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout << #x << " :: " << x << "\n";
#define debug2(x, y) ... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 1 | 541 |
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
class union_find {
public:
union_find(int N) {
parent = new int[N];
rank = new int[N];
for (int i = 0; i < N; i++) {
parent[i] = i;
rank[i] = 0;
}
}
int root(in... | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
class union_find {
public:
union_find(int N) {
parent = new int[N];
rank = new int[N];
for (int i = 0; i < N; i++) {
parent[i] = i;
rank[i] = 0;
}
}
int root(in... | [["-", 28, 69, 341, 342, 0, 2, 63, 118, 119, 120], ["+", 28, 69, 341, 342, 0, 2, 63, 118, 119, 120]] | 1 | 440 |
from collections import deque
N, M = map(int, input().split())
friends = [[] for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
a, b = a-1, b-1
friends[a].append(b)
friends[b].append(a)
check = [False] * N
ans = 0
for i in range(N):
if check[i] == False:
check[i] = True
D = deq... | from collections import deque
N, M = map(int, input().split())
friends = [[] for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
a, b = a-1, b-1
friends[a].append(b)
friends[b].append(a)
check = [False] * N
ans = 0
for i in range(N):
if check[i] == False:
check[i] = True
D = deq... | [["-", 0, 57, 64, 196, 0, 7, 12, 206, 206, 22], ["+", 0, 57, 64, 196, 0, 7, 12, 206, 206, 22]] | 5 | 183 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
# xの属する木の根を求める
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
# xとyの属す... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
# xの属する木の根を求める
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
# xとyの属す... | [["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21]] | 5 | 425 |
#include <bits/stdc++.h>
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define int int64_t
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<ii>
#define vv... | #include <bits/stdc++.h>
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define int int64_t
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<ii>
#define vv... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 354 |
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
class DisjointSet {
public:
vector<ll> Parent, Rank, Size;
ll MaxSize = -1;
DisjointSet(ll n) {
forn(i, n + 1) Parent.push_back(i), Rank.push_back(0), Size.push_back(1);
}... | #include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
class DisjointSet {
public:
vector<ll> Parent, Rank, Size;
ll MaxSize = 1;
DisjointSet(ll n) {
forn(i, n + 1) Parent.push_back(i), Rank.push_back(0), Size.push_back(1);
}
... | [["-", 0, 30, 0, 353, 8, 123, 0, 124, 365, 13], ["+", 0, 30, 0, 353, 8, 123, 0, 124, 365, 13]] | 1 | 307 |
class UnionFind:
"""素集合を木構造として管理する"""
def __init__(self, n):
self.parent = [-1] * n
self.cnt = n
def root(self, x):
"""要素xの根を求める"""
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.root(self.parent[x])
return self.parent... | class UnionFind:
"""素集合を木構造として管理する"""
def __init__(self, n):
self.parent = [-1] * n
self.cnt = n
def root(self, x):
"""要素xの根を求める"""
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.root(self.parent[x])
return self.parent... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]] | 5 | 323 |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
int p[200010], cnt[200010];
int find(int x) {
if (p[x] != x)
p[x] = find(p[x]);
return p[x];
}
int main() {
int n, m;
int a... | #include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
int p[200010], cnt[200010];
int find(int x) {
if (p[x] != x)
p[x] = find(p[x]);
return p[x];
}
int main() {
int n, m;
int a... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 219 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
#define Fi first
#define Se second
#define _Out(a) cerr << #a << " = " << (a) << endl
const int INF = 0x3f3f3f3f, MAXN = 1e3 ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
#define Fi first
#define Se second
#define _Out(a) cerr << #a << " = " << (a) << endl
const int INF = 0x3f3f3f3f, MAXN = 3e5 ... | [["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 1,224 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 2 * 1e05 + 1;
vector<vector<int>> g(INF);
vector<int> visited(INF);
int cnt;
void dfs(int now) {
visited[now] = 1;
for (int next : g[now]) {
if (visited[next])
continue;
cnt++;
dfs(next);
}
}
int main() {
in... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 2 * 1e05 + 1;
vector<vector<int>> g(INF);
vector<int> visited(INF);
int cnt;
void dfs(int now) {
visited[now] = 1;
for (int next : g[now]) {
if (visited[next])
continue;
cnt++;
dfs(next);
}
}
int main() {
in... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 210 |
def root(x):
if F[x] < 0:
return x
else:
F[x] = root(F[x])
return F[x]
def unite(x, y):
rx = root(x)
ry = root(y)
if rx == ry:
return
if rx > ry:
x, y = y, x
F[x] += F[y]
F[y] = x
N, M = map(int, input().split())
F = [-1] * N
for m in range(M):
a, b = map(int, input().split())
... | def root(x):
if F[x] < 0:
return x
else:
F[x] = root(F[x])
return F[x]
def unite(x, y):
x = root(x)
y = root(y)
if x == y:
return
if x > y:
x, y = y, x
F[x] += F[y]
F[y] = x
N, M = map(int, input().split())
F = [-1] * N
for m in range(M):
a, b = map(int, input().split())
unite... | [["-", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22]] | 5 | 167 |
from collections import deque
N, M = map(int, input().split())
g = {i:set() for i in range(N)}
v = [-1 for i in range(N)]
for _ in range(M):
a, b = map(int, input().split())
a, b = a-1, b-1
g[a].add(b)
g[b].add(a)
Q = deque()
ans = 0
for a in g:
if v[a]==-1:
v[a] = 1
ans_tmp = 1
Q.append(a)
... | from collections import deque
N, M = map(int, input().split())
g = {i:set() for i in range(N)}
v = [-1 for i in range(N)]
for _ in range(M):
a, b = map(int, input().split())
a, b = a-1, b-1
g[a].add(b)
g[b].add(a)
Q = deque()
ans = 0
for a in g:
if v[a]==-1:
v[a] = 1
ans_tmp = 1
Q.append(a)
... | [["-", 0, 52, 8, 196, 0, 7, 12, 206, 206, 22], ["+", 0, 52, 8, 196, 0, 7, 12, 206, 206, 22]] | 5 | 198 |
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define REP(a, b) for (int a = 0; a < (b); ++a)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)
#define debug(x) cerr << #x << ": " << x << '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES() pri... | #include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define REP(a, b) for (int a = 0; a < (b); ++a)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)
#define debug(x) cerr << #x << ": " << x << '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES() pri... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 1,029 |
class unionfind():
def __init__(self,n):
#親番号<0なら根
#根の場合、数値の絶対値が要素数
self.par=[-1 for i in range(n)]
def root(self,x):
par=self.par
if par[x]<0:
return x
else:
self.root = self.root(par[x])
return self.root
... |
class unionfind():
def __init__(self,n):
#親番号<0なら根
#根の場合、数値の絶対値が要素数
self.par=[-1 for i in range(n)]
def root(self,x):
par=self.par
if par[x]<0:
return x
else:
self.x = self.root(par[x])
return self.x
... | [["-", 8, 196, 0, 1, 0, 662, 31, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 319, 319, 22], ["-", 75, 76, 8, 196, 0, 37, 0, 319, 319, 22], ["+", 75, 76, 8, 196, 0, 37, 0, 319, 319, 22]] | 5 | 275 |
n, m = gets.split.map(&:to_i)
relations = []
m.times do
relations << gets.split.map(&:to_i)
end
graph = Array.new(n) { [] }
relations.each do |a, b|
graph[a - 1] << b - 1
graph[b - 1] << a - 1
end
groups = []
0.upto(n - 1) do |leader|
next if groups[leader]
queue = [leader]
until queue.empty?
curre... | n, m = gets.split.map(&:to_i)
relations = []
m.times do
relations << gets.split.map(&:to_i)
end
graph = Array.new(n) { [] }
relations.each do |a, b|
graph[a - 1] << b - 1
graph[b - 1] << a - 1
end
groups = []
0.upto(n - 1) do |leader|
next if groups[leader]
queue = [leader]
until queue.empty?
curre... | [["-", 196, 737, 8, 736, 0, 662, 31, 742, 500, 22], ["-", 196, 737, 8, 736, 0, 662, 31, 742, 0, 70], ["-", 196, 737, 8, 736, 0, 662, 31, 742, 0, 22], ["-", 196, 737, 8, 736, 0, 662, 31, 742, 0, 73], ["-", 0, 652, 196, 737, 8, 736, 0, 662, 0, 32], ["-", 0, 652, 196, 737, 8, 736, 0, 662, 12, 22]] | 4 | 159 |
#include <bits/stdc++.h>
#define MX 200005
using namespace std;
vector<int> adj[MX];
int vis[MX];
int dfs(int u) {
int ret = 1;
vis[u] = 1;
for (int v : adj[u])
if (!vis[v])
ret += dfs(v);
return ret;
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> ... | #include <bits/stdc++.h>
#define MX 200005
using namespace std;
vector<int> adj[MX];
int vis[MX];
int dfs(int u) {
int ret = 1;
vis[u] = 1;
for (int v : adj[u])
if (!vis[v])
ret += dfs(v);
return ret;
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> ... | [["+", 0, 7, 8, 57, 15, 339, 51, 91, 17, 111], ["-", 0, 7, 8, 57, 15, 339, 51, 16, 17, 79], ["-", 0, 7, 8, 57, 15, 339, 51, 16, 12, 13]] | 1 | 185 |
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
class UnionFind {
public:
UnionFind(int &n) { r = vector<int>(n + 1, -1); }
int findRoot(int x) {
if (r[x] < 0)
return x... | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
class UnionFind {
public:
UnionFind(int &n) { r = vector<int>(n + 1, -1); }
int findRoot(int x) {
if (r[x] < 0)
return x... | [["-", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 75, 76, 0, 1, 0, 11, 31, 69, 28, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 73], ["-", 0, 57, 75, 76, 0, 1, 0, 11, 17, 32], ["+", 8, 123, 0, 14, 8, 9, 0, 37, 0, 38]] | 1 | 290 |
n, m = gets.split.map(&:to_i)
edges = []
m.times { edges << gets.chomp.split.map(&:to_i) }
graph = Array.new(n + 1) { Array.new }
edges.each do |from, to|
graph[from] << to
graph[to] << from
end
belongs_to = Array.new(n)
n.times do |from|
next if belongs_to[from]
belongs_to[from] = from
queue = [from]
until... | n, m = gets.split.map(&:to_i)
edges = []
m.times { edges << gets.chomp.split.map(&:to_i) }
graph = Array.new(n + 1) { Array.new }
edges.each do |from, to|
graph[from] << to
graph[to] << from
end
belongs_to = Array.new(n)
n.times do |from|
next if belongs_to[from]
belongs_to[from] = from
queue = [from]
until... | [["+", 0, 652, 196, 737, 8, 736, 0, 738, 31, 22], ["+", 0, 652, 196, 737, 8, 736, 0, 738, 17, 151], ["+", 0, 652, 196, 737, 8, 736, 0, 738, 12, 22]] | 4 | 146 |
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 100;
int fa[N], son_num[N];
int Find(int x) {
if (fa[x] == x)
return fa[x];
else
return fa[x] = Find(fa[x]);
}
void Union(int x, int y) {
int fax = Find(x);
int fay = Find(y);
if (fax != fay) {
fa[y] = fax;
son_num[fax] +... | #include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 100;
int fa[N], son_num[N];
int Find(int x) {
if (fa[x] == x)
return fa[x];
else
return fa[x] = Find(fa[x]);
}
void Union(int x, int y) {
int fax = Find(x);
int fay = Find(y);
if (fax != fay) {
fa[fay] = fax;
son_num[fax]... | [["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]] | 1 | 222 |
n, m = gets.split(" ").map(&:to_i)
@ind_arr = Array.new(n+1){|i| i}
@f_arr = Array.new(n+1, 1)
def find(x)
return x if x == @ind_arr[x]
# 途中のindexも更新しておく
@ind_arr[x] = find(@ind_arr[x])
return @ind_arr[x]
end
def union(x, y)
x = find(x)
y = find(y)
return if x == y
@ind_arr[x] = y
@f_arr[y] += @f_a... | n, m = gets.split(" ").map(&:to_i)
@ind_arr = Array.new(n+1){|i| i}
@f_arr = Array.new(n+1, 1)
def find(x)
return x if x == @ind_arr[x]
# 途中のindexも更新しておく
@ind_arr[x] = find(@ind_arr[x])
return @ind_arr[x]
end
def union(x, y)
x = find(x)
y = find(y)
return if x == y
@ind_arr[x] = y
@f_arr[y] += @f_a... | [["-", 0, 493, 0, 652, 3, 4, 0, 652, 486, 22], ["+", 0, 493, 0, 652, 3, 4, 0, 652, 486, 777]] | 4 | 178 |
#include <stdio.h>
#include <stdlib.h>
int t[300000];
int c[300000];
int root(int x) {
if (t[x] == x)
return x;
return t[x] = root(t[x]);
}
int main() {
int N, M;
scanf("%d %d", &N, &M);
for (int i = 1; i <= N; i++) {
t[i] = i;
c[i] = 1;
}
int A, B, RA, RB;
for (int i = 1; i <= M; i++) {
... | #include <stdio.h>
#include <stdlib.h>
int t[300000];
int c[300000];
int root(int x) {
if (t[x] == x)
return x;
return t[x] = root(t[x]);
}
int main() {
int N, M;
scanf("%d %d", &N, &M);
for (int i = 1; i <= N; i++) {
t[i] = i;
c[i] = 1;
}
int A, B, RA, RB;
for (int i = 1; i <= M; i++) {
... | [["-", 64, 9, 0, 1, 0, 11, 31, 69, 71, 22], ["+", 64, 9, 0, 1, 0, 11, 31, 69, 71, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 69, 71, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 71, 22]] | 0 | 251 |
#include <iostream>
#include <vector>
using namespace std;
int root(int x, vector<int> &par) {
return par.at(x) == x ? x : par.at(x) = root(par.at(x), par);
}
int unite(int x, int y, vector<int> &par, vector<int> &rank) {
x = root(x, par);
y = root(y, par);
if (x == y)
return -1;
if (rank.at(x) < rank.a... | #include <iostream>
#include <vector>
using namespace std;
int root(int x, vector<int> &par) {
return par.at(x) == x ? x : par.at(x) = root(par.at(x), par);
}
int unite(int x, int y, vector<int> &par, vector<int> &rank) {
x = root(x, par);
y = root(y, par);
if (x == y)
return -1;
if (rank.at(x) < rank.a... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 312 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | [["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 491 |
#Union Find
#xの根を求める
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
#xとyの属する集合の併合
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
else:
#sizeの大きいほうがx
if par[x] > par[y]:
x,y = y,x
... | #Union Find
#xの根を求める
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
#xとyの属する集合の併合
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
else:
#sizeの大きいほうがx
if par[x] > par[y]:
x,y = y,x
... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 210 |
#include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll l... | #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll l... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]] | 1 | 567 |
#include <bits/stdc++.h>
using namespace std;
using namespace __detail;
typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#defi... | #include <bits/stdc++.h>
using namespace std;
using namespace __detail;
typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#defi... | [["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]] | 1 | 547 |
from collections import defaultdict, deque
n, m = map(int, input().split())
g = defaultdict(set)
if m == 0:
print(n)
else:
for _ in range(m):
a, b = map(int, input().split())
g[a - 1].add(b - 1)
g[b - 1].add(a - 1)
visited = [False]*n
ans = 0
for i in range(n):
if... | from collections import defaultdict, deque
n, m = map(int, input().split())
g = defaultdict(set)
if m == 0:
print(1)
else:
for _ in range(m):
a, b = map(int, input().split())
g[a - 1].add(b - 1)
g[b - 1].add(a - 1)
visited = [False]*n
ans = 0
for i in range(n):
if... | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["-", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 267]] | 5 | 189 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(r) cout << r << endl
#define prints(r) cout << r << " "
#define printline cout << endl
vector<ll> desc(2e5, 1);
vector<vector<ll>> tree(2e5);
vector<ll> visited(2e5, 0);
ll dfs(ll n) {
if (visited[n])
return 0;
visited[n] = 1;
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(r) cout << r << endl
#define prints(r) cout << r << " "
#define printline cout << endl
vector<ll> desc(2e5, 1);
vector<vector<ll>> tree(2e5);
vector<ll> visited(2e5, 0);
ll dfs(ll n) {
if (visited[n])
return 0;
visited[n] = 1;
... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 297 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
struct Edge {
long long to;
long long cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
const long long INF = 1LL << 60;
#defin... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
struct Edge {
long long to;
long long cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
const long long INF = 1LL << 60;
#defin... | [["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]] | 1 | 1,856 |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
struct UnionFind {
vector<int> par;
UnionFind(int N) { par ... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
struct UnionFind {
vector<int> par;
UnionFind(int N) { par ... | [["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]] | 1 | 338 |
#include <bits/stdc++.h>
#define pb push_back
#define f(i, a, b) for (int i = a; i < b; i++)
#define f1(i, a, b) for (int i = a; i <= b; i++)
#define int long long
using namespace std;
#define mod 1000000007
vector<int> adj[200001];
int visited[200001];
int dfs(int s) {
visited[s] = 1;
int count = 1;
for (int i ... | #include <bits/stdc++.h>
#define pb push_back
#define f(i, a, b) for (int i = a; i < b; i++)
#define f1(i, a, b) for (int i = a; i <= b; i++)
#define int long long
using namespace std;
#define mod 1000000007
vector<int> adj[200001];
int visited[200001];
int dfs(int s) {
visited[s] = 1;
int count = 1;
for (int i ... | [["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13]] | 1 | 327 |
// abc177_d.cpp
// Sat Aug 29 20:53:41 2020
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i, n) for (in... | // abc177_d.cpp
// Sat Aug 29 20:53:41 2020
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i, n) for (in... | [["-", 0, 27, 28, 69, 341, 342, 0, 69, 28, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 25]] | 1 | 372 |
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define COUT(x) cout << (x) << "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); ... | #include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define COUT(x) cout << (x) << "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); ... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 501 |
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
int cnt = 1;
// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
seen[v] = true;
for (auto next_v : G[v]) {
if (seen[next_v])
continue;
dfs(G, next_v); // 再帰的に探索
cnt++;
}
}
int main() {
... | #include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
int cnt = 1;
// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
seen[v] = true;
for (auto next_v : G[v]) {
if (seen[next_v])
continue;
dfs(G, next_v); // 再帰的に探索
cnt++;
}
}
int main() {
... | [["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 229 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int INF = 1e9;
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#defin... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int INF = 1e9;
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#defin... | [["-", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120]] | 1 | 591 |
/*
ID: Loxilante
Time: 2020/08/29
Prog: D
Lang: cpp
*/
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#endif
#include <bits/extc++.h>
#define rep(i, l, r) for (int i = l; i < r; i++)
#define hrp(i, l, r) for (int i = l; i <= r; i++)
#define rev(i, r, l) for (int i = r; i >= l; i--)
#defi... | /*
ID: Loxilante
Time: 2020/08/29
Prog: D
Lang: cpp
*/
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#endif
#include <bits/extc++.h>
#define rep(i, l, r) for (int i = l; i < r; i++)
#define hrp(i, l, r) for (int i = l; i <= r; i++)
#define rev(i, r, l) for (int i = r; i >= l; i--)
#defi... | [["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 27, 28, 69, 341, 342, 0, 69, 28, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 25]] | 1 | 382 |
from collections import deque, defaultdict
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
vertexes = set()
edges = defaultdict(set)
for a, b in AB:
edges[a].add(b)
edges[b].add(a)
vertexes.add(a)
vertexes.add(b)
res = 0
while vertexes:
v = vertexes.pop... | from collections import deque, defaultdict
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
vertexes = set()
edges = defaultdict(set)
for a, b in AB:
edges[a].add(b)
edges[b].add(a)
vertexes.add(a)
vertexes.add(b)
res = 1
while vertexes:
v = vertexes.pop... | [["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]] | 5 | 173 |
#include <bits/stdc++.h> // header file includes every Standard library
using namespace std;
#define mod 1000000007
// finding root of an element.
int root(int Arr[], int i) {
while (Arr[i] != i) {
Arr[i] = Arr[Arr[i]];
i = Arr[i];
}
return i;
}
/*modified union function where we connect the elements by ... | #include <bits/stdc++.h> // header file includes every Standard library
using namespace std;
#define mod 1000000007
// finding root of an element.
int root(int Arr[], int i) {
while (Arr[i] != i) {
Arr[i] = Arr[Arr[i]];
i = Arr[i];
}
return i;
}
/*modified union function where we connect the elements by ... | [["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["+", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 21], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, ... | 1 | 256 |
class UnionFind():
#https://note.nkmk.me/python-union-find/
#note.nkmk.me 2019-08-18
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x]... | class UnionFind():
#https://note.nkmk.me/python-union-find/
#note.nkmk.me 2019-08-18
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x]... | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]] | 5 | 440 |
#include <bits/stdc++.h>
using namespace std;
#define Pi 2 * acos(0.0)
#define LINF 1LL << 63
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define MAX 500006
#define MAX1 10000008
#define mem(a, v) memset(a, v, sizeof(a))
#define all(x) x.begin(), x.end()
#define lcm(a,... | #include <bits/stdc++.h>
using namespace std;
#define Pi 2 * acos(0.0)
#define LINF 1LL << 63
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define MAX 500006
#define MAX1 10000008
#define mem(a, v) memset(a, v, sizeof(a))
#define all(x) x.begin(), x.end()
#define lcm(a,... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]] | 1 | 622 |
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include <algorithm>
#include <bits/stdc++.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#def... | /*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include <algorithm>
#include <bits/stdc++.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#def... | [["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12,... | 1 | 523 |
n,m = map(int,input().split())
if m == 0:
print(1)
import sys
sys.exit()
u = []
graph = [[] for _ in range(n)]
for i in range(m):
a,b = map(int,input().split())
a-=1
b-=1
graph[a].append(b)
graph[b].append(a)
dist = [-1]*n
from collections import deque
q = deque([])
def bfs(vert,num):... | n,m = map(int,input().split())
if m == 0:
print(1)
import sys
sys.exit()
u = []
graph = [[] for _ in range(n)]
for i in range(m):
a,b = map(int,input().split())
a-=1
b-=1
graph[a].append(b)
graph[b].append(a)
dist = [-1]*n
from collections import deque
q = deque([])
def bfs(vert,num):... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 22]] | 5 | 223 |
#include <bits/stdc++.h>
using namespace std;
int par[200001], ran[200001], box[200001];
int main(void) {
int n, m, x, y, i;
cin >> n >> m;
for (i = 1; i <= n; i++) {
par[i] = i;
ran[i] = 0;
box[i] = 0;
}
for (i = 0; i < m; i++) {
cin >> x >> y;
if (x < y)
swap(x, y);
while (x !=... | #include <bits/stdc++.h>
using namespace std;
int par[200001], ran[200001], box[200001];
int main(void) {
int n, m, x, y, i;
cin >> n >> m;
for (i = 1; i <= n; i++) {
par[i] = i;
ran[i] = 0;
box[i] = 0;
}
for (i = 0; i < m; i++) {
cin >> x >> y;
if (x < y)
swap(x, y);
while (x !=... | [["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["-", 8, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 8, 1, 0, 11, 12, 69, 341, 342, 0, 22]] | 1 | 271 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans = 0;
int par[200001] = {};
int r[200001] = {};
int si[200001] = {};
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans = 1;
int par[200001] = {};
int r[200001] = {};
int si[200001] = {};
int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]] | 1 | 298 |
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 2e5 + 10;
int p[N], se[N], ans;
int n, m;
int find(int x) {
if (p[x] != x)
p[x] = find(p[x]);
return p[x];
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++)
p[i] = i, se[i] = 1;
for (int i = 0;... | #include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 2e5 + 10;
int p[N], se[N], ans;
int n, m;
int find(int x) {
if (p[x] != x)
p[x] = find(p[x]);
return p[x];
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++)
p[i] = i, se[i] = 1;
for (int i = 0;... | [["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 12, 2, 3, 4, 0, 69, 341, 342, 0, 22]] | 1 | 218 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
#define ll long long
#define ios std::ios::sync_with_stdio(false)
const ll INF(0x3f3f3f3f3f3f3f3fll);
const int inf(0x3f3f3f3f);
#define int long long
#define pb(a) push_back(a)
#define debug(a) cout << "a : " << a << '\n'
#define mp(a, b) make_pa... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
#define ll long long
#define ios std::ios::sync_with_stdio(false)
const ll INF(0x3f3f3f3f3f3f3f3fll);
const int inf(0x3f3f3f3f);
#define int long long
#define pb(a) push_back(a)
#define debug(a) cout << "a : " << a << '\n'
#define mp(a, b) make_pa... | [["-", 0, 27, 28, 69, 341, 342, 0, 69, 28, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 25]] | 1 | 438 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template <typename T> T gcd(T a, T b)... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template <typename T> T gcd(T a, T b)... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 497 |
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set \
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, ... | #include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set \
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 941 |
n,m = map(int,input().split())
t = [0]*n
q = []
r = 0
for i in range(n):
q.append([])
for i in range(m):
a,b = map(int,input().split())
q[a-1].append(b-1)
q[b-1].append(a-1)
num = 0
for i in range(n):
if(t[i] == 0):
num += 1
cnt = 0
stc = [i]
while(len(stc) > cnt):
... | n,m = map(int,input().split())
t = [0]*n
q = []
r = 1
for i in range(n):
q.append([])
for i in range(m):
a,b = map(int,input().split())
q[a-1].append(b-1)
q[b-1].append(a-1)
num = 0
for i in range(n):
if(t[i] == 0):
num += 1
cnt = 0
stc = [i]
while(len(stc) > cnt):
... | [["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]] | 5 | 214 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.