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
#include <stdio.h> int main(void) { int n = 0; scanf("%d", &n); for (int i = 0; i == n; i++) { printf("ACL"); } }
#include <stdio.h> int main(void) { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { printf("ACL"); } }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 60], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
0
47
k=int(input()) k+=1 o='' a='ALC' if k==1: print('') exit() else: for i in range(1,k): o=o+a print(o)
k=int(input()) k+=1 o='' a='ACL' if k==1: print('') exit() else: for i in range(1,k): o=o+a print(o)
[["-", 0, 656, 0, 1, 0, 662, 12, 557, 0, 6], ["+", 0, 656, 0, 1, 0, 662, 12, 557, 0, 6]]
5
54
K=input() r='ACL' for i in range(1,int(k)): r='ACL'+ r print(r)
K=input() r='ACL' for i in range(1,int(K)): r='ACL'+ r print(r)
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
34
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long int #define rep(i, a, b) for (int i = a; i < b; i++) #define revrep(i, a, b) for (int i = a; i >= b; i--) #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define min3(a, b, c) min(a, mi...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long int #define rep(i, a, b) for (int i = a; i < b; i++) #define revrep(i, a, b) for (int i = a; i >= b; i--) #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define min3(a, b, c) min(a, mi...
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
155
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String res = ""; while (n-- > 0) { res.concat("ACL"); } System.out.println(res); } }
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String res = ""; while (n-- > 0) { res = res + "ACL"; } System.out.println(res); } }
[["-", 0, 52, 8, 196, 0, 1, 0, 492, 0, 131], ["-", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25]]
3
77
#include <bits/stdc++.h> using namespace std; #define ll long long #define inf 1e18 #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define inf 1e18 #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
[["-", 8, 9, 0, 43, 49, 50, 51, 5, 0, 6]]
1
203
import java.io.*; import java.util.*; public class Main { final static long mod = 1000000007; static void debug(Object... args) { System.out.println(Arrays.deepToString(args)); } public static void main(String[] args) { InputReader sc = new InputReader(System.in); PrintWriter pw = new PrintWriter(Sy...
import java.io.*; import java.util.*; public class Main { final static long mod = 1000000007; static void debug(Object... args) { System.out.println(Arrays.deepToString(args)); } public static void main(String[] args) { InputReader sc = new InputReader(System.in); PrintWriter pw = new PrintWriter(Sy...
[["-", 0, 492, 3, 4, 0, 492, 500, 5, 0, 491], ["+", 0, 492, 3, 4, 0, 492, 500, 5, 0, 491]]
3
954
#include <algorithm> #include <cmath> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; int main() { int K; cin >> K; for (int i = 0; i < K; i++) { cout << "ALC"; } cout << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <set> #include <string> #include <vector> using namespace std; int main() { int K; cin >> K; for (int i = 0; i < K; i++) { cout << "ACL"; } cout << endl; }
[["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
55
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 1000000007; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) int main(void) { int k; cin >> k; rep(i, k) puts("ACL"); cout << endl; re...
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 1000000007; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) int main(void) { int k; cin >> k; rep(i, k) cout << "ACL"; cout << endl; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 16, 0, 42, 0, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]]
1
83
#include <stdio.h> int main(int argc, const char *argv[]) { // insert code here... int x, i = 0; scanf("%d", &x); while (i <= x) { printf("ACL"); i++; } return 0; }
#include <stdio.h> int main(int argc, const char *argv[]) { // insert code here... int x, i = 0; scanf("%d", &x); while (i < x) { printf("ACL"); i++; } return 0; }
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 19], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 17, 18]]
0
56
#include <stdio.h> int main() { int n; char T[3] = {'A', 'L', 'C'}; scanf("%d", &n); for (int i = 0; i < n; i++) printf("%c%c%c", T[0], T[1], T[2]); return 0; }
#include <stdio.h> int main() { int n; char T[3] = {'A', 'C', 'L'}; scanf("%d", &n); for (int i = 0; i < n; i++) printf("%c%c%c", T[0], T[1], T[2]); return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 103, 0, 125], ["+", 0, 43, 49, 50, 51, 83, 0, 103, 0, 125]]
0
80
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; string k = "ACL"; for (int i = 0; i < 5; i++) k += "ACL"; cout << k; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; string k = "ACL"; for (int i = 0; i < n - 1; i++) k += "ACL"; cout << k; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
58
def solve(): K = int(input()) for i in range(K): print("ALC", end="") if __name__ == "__main__": solve()
def solve(): K = int(input()) for i in range(K): print("ACL", end="") if __name__ == "__main__": solve()
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
42
k=input() for i in range(k): print("ACL",end="")
k = int(input()) for i in range(k): print("ACL",end="")
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
24
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; for (int i = 0; i < K; i++) cout << "ALC"; }
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; for (int i = 0; i < K; i++) cout << "ACL"; }
[["-", 0, 7, 8, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 7, 8, 1, 0, 16, 12, 5, 0, 6]]
1
39
#a k=int(input()) ans=[] for i in range(k): ans.append('acl') a=''.join(ans) print(a)
#a k=int(input()) ans=[] for i in range(k): ans.append('ACL') a=''.join(ans) print(a)
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
42
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; string s = ""; for (int i = 0; i < k; i++) s += 'ACL'; cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; string s = ""; for (int i = 0; i < k; i++) s += "ACL"; cout << s << endl; return 0; }
[["-", 0, 7, 8, 1, 0, 11, 12, 103, 0, 104], ["-", 0, 7, 8, 1, 0, 11, 12, 103, 0, 125], ["-", 8, 1, 0, 11, 12, 103, 0, 42, 0, 22], ["+", 0, 7, 8, 1, 0, 11, 12, 5, 0, 62], ["+", 0, 7, 8, 1, 0, 11, 12, 5, 0, 6]]
1
55
k = input() str = '' for _ in range(k): str += 'ACL' print(str)
k = int(input()) str = '' for _ in range(k): str += 'ACL' print(str)
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
26
K = int(input()) a = "" for i in range(K): a += "ALT" print("{}".format(a))
K = int(input()) a = "" for i in range(K): a += "ACL" print("{}".format(a))
[["-", 8, 196, 0, 1, 0, 677, 12, 557, 0, 6], ["+", 8, 196, 0, 1, 0, 677, 12, 557, 0, 6]]
5
36
if __name__=="__main__": n=int(input()) print('ACL'*k)
if __name__=="__main__": k=int(input()) print('ACL'*k)
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
23
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define pf push_front #define eb emplace_back #define emp emplace #define ins insert #define mp make_pair #define mt make_tuple #define sz(s) (int)s.size() #define forp(i, a, b) for (int i = a; i <= b; i++) #define rep(i, n) for (int i = 0...
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define pf push_front #define eb emplace_back #define emp emplace #define ins insert #define mp make_pair #define mt make_tuple #define sz(s) (int)s.size() #define forp(i, a, b) for (int i = a; i <= b; i++) #define rep(i, n) for (int i = 0...
[["-", 8, 9, 0, 43, 49, 50, 51, 5, 0, 6]]
1
721
#include <bits/stdc++.h> using namespace std; int main() { int t; string ans, p = "ACL"; while (t > 0) { ans += p; t--; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; string ans, p = "ACL"; while (t > 0) { ans += p; t--; } cout << ans; return 0; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
46
import java.util.*; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String s = ""; for (int i = 0; i < n; i++) { s.concat("ACL"); } System.out.println(s); } }
import java.util.*; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String s = ""; for (int i = 0; i < n; i++) { s = s.concat("ACL"); } System.out.println(s); } }
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 492, 500, 22]]
3
84
#include <bits/stdc++.h> using namespace std; //#define cin fi //#define cout fo // ifstream fi (".INP"); // ofstream fo (".INP"); int main() { // freopen("test.txt" , "r" , stdin); // ios_base:: sync_with_stdio(false); // cin.tie(0); // cout.tie(0); int k; while (k--) { cout << "ACL"; } return ...
#include <bits/stdc++.h> using namespace std; //#define cin fi //#define cout fo // ifstream fi (".INP"); // ofstream fo (".INP"); int main() { // freopen("test.txt" , "r" , stdin); // ios_base:: sync_with_stdio(false); // cin.tie(0); // cout.tie(0); int k; cin >> k; while (k--) { cout << "ACL"; ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
39
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io() { std:...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io() { std:...
[["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
123
k = int(input()) X= "ACL" print(X*3)
k = int(input()) X= "ACL" print(X*k)
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
19
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int S; for (int i = 0; i < S; i++) cout << "ACL"; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int S; cin >> S; for (int i = 0; i < S; i++) cout << "ACL"; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
41
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i <= n; i++) { cout << "ACL"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cout << "ACL"; } return 0; }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
44
n = int(input()) a = ["ACL"]*n print('',join(a))
n = int(input()) a = ["ACL"]*n print(''.join(a))
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131]]
5
27
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; for (int i = 1; i <= k; i++) cout << "ACL" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; for (int i = 1; i <= k; i++) cout << "ACL"; return 0; }
[["-", 8, 9, 0, 7, 8, 1, 0, 16, 17, 151], ["-", 8, 9, 0, 7, 8, 1, 0, 16, 12, 22]]
1
44
#include <stdio.h> int main() { int k; scanf("%d", &k); for (int i = 0; i < k; i++) { printf("ALC"); } return 0; }
#include <stdio.h> int main() { int k; scanf("%d", &k); for (int i = 0; i < k; i++) { printf("ACL"); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
47
#include <bits/stdc++.h> #if __has_include("debug.h") #include "debug.h" #endif using namespace std; typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; typedef vector<ii> vii; #define pb push_back #define ff first #define ss second #define rep(i, a, b) for (ll i = a; i < b; ++i) #define rep_(i, a, ...
#include <bits/stdc++.h> #if __has_include("debug.h") #include "debug.h" #endif using namespace std; typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; typedef vector<ii> vii; #define pb push_back #define ff first #define ss second #define rep(i, a, b) for (ll i = a; i < b; ++i) #define rep_(i, a, ...
[["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
407
#include <bits/stdc++.h> #include <iostream> #include <math.h> #include <string> using namespace std; #define nl endl #define in cin #define out cout #define ll long long // sort(y,y+j, greater<int> ll x[1000000]; int main() { ll a, b, c, d, e, i, j, k = 0, n, sq, mul, r; char s[10000], z[1000]; in >> a; for (i...
#include <bits/stdc++.h> #include <iostream> #include <math.h> #include <string> using namespace std; #define nl endl #define in cin #define out cout #define ll long long // sort(y,y+j, greater<int> ll x[1000000]; int main() { ll a, b, c, d, e, i, j, k = 0, n, sq, mul, r; char s[10000], z[1000]; in >> a; for (i...
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22]]
1
102
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; #define rep(i, n) for (ll i = 0; i < n; i++)...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; #define rep(i, n) for (ll i = 0; i < n; i++)...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
480
/* ChampionsNeverFall :)*/ #include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ff first #define ss second #define all(v) v.begin(), v.end()...
/* ChampionsNeverFall :)*/ #include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ff first #define ss second #define all(v) v.begin(), v.end()...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
619
def main(sample_file = ''): """ convenient functions # for i, a in enumerate(iterable) # q, mod = divmod(a, b) # divmod(x, y) returns the tuple (x//y, x%y) # Higher-order function: reduce(operator.mul, xyz_count, 1) # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc...
def main(sample_file = ''): """ convenient functions # for i, a in enumerate(iterable) # q, mod = divmod(a, b) # divmod(x, y) returns the tuple (x//y, x%y) # Higher-order function: reduce(operator.mul, xyz_count, 1) # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
2,791
#include <bits/stdc++.h> #define maxn 100086 using namespace std; int n, m; int fa[maxn]; int x, y, ans; int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) fa[i] = i; while (m--) { scanf("%d%d", &x, &y); x = find(x), y...
#include <bits/stdc++.h> #define maxn 100086 using namespace std; int n, m; int fa[maxn]; int x, y, ans; int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) fa[i] = i; while (m--) { scanf("%d%d", &x, &y); x = find(x), y...
[["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33]]
1
159
#include <bits/stdc++.h> #define mod 1000000007 #define ll long long int #define pb push_back #define mk make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define frr(j, i, n) for (int i = j; i <= n; ++i) using namespace std; vector<int> g[100005]; int vis[100005]; void dfs(int node) { vis[node]++; for ...
#include <bits/stdc++.h> #define mod 1000000007 #define ll long long int #define pb push_back #define mk make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define frr(j, i, n) for (int i = j; i <= n; ++i) using namespace std; vector<int> g[100005]; int vis[100005]; void dfs(int node) { vis[node]++; for ...
[["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
227
import sys def input(): return sys.stdin.readline()[:-1] N,M=map(int,input().split()) sys.setrecursionlimit(200000) class uf: def __init__(self,n): self.n=n self.l=[-1]*n def ro(self,n): #root if self.l[n]<0: return n r=self.ro(self.l[n]) self.l[n]...
import sys def input(): return sys.stdin.readline()[:-1] N,M=map(int,input().split()) sys.setrecursionlimit(200000) class uf: def __init__(self,n): self.n=n self.l=[-1]*n def ro(self,n): #root if self.l[n]<0: return n r=self.ro(self.l[n]) self.l[n]...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
431
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vll; #define fi first #define print(v) \ for (ll i : v) \ cout << i << ss #de...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vll; #define fi first #define print(v) \ for (ll i : v) \ cout << i << ss #de...
[["-", 15, 339, 51, 91, 28, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 91, 28, 69, 341, 342, 0, 22]]
1
267
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, data_size: int) -> None: self._data_size = data_size self._roots = [-1] * data_size def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def ...
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, data_size: int) -> None: self._data_size = data_size self._roots = [-1] * data_size def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def ...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
290
#include <bits/stdc++.h> #define rep(i, m) for (long long i = 0; i < m; i++) #define per(i, m) for (long long i = m - 1; i >= 0; i--) #define FOR(i, n, m) for (long long i = n; i < m; i++) #define ROF(i, n, m) for (long long i = m - 1; i >= n; i--) #define SORT(v, n) ...
#include <bits/stdc++.h> #define rep(i, m) for (long long i = 0; i < m; i++) #define per(i, m) for (long long i = m - 1; i >= 0; i--) #define FOR(i, n, m) for (long long i = n; i < m; i++) #define ROF(i, n, m) for (long long i = m - 1; i >= n; i--) #define SORT(v, n) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
4,800
class UnionFind(): def __init__(self, n): self.parents = list(range(n)) def find(self, x): if self.parents[x] == x: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x)...
class UnionFind(): def __init__(self, n): self.parents = list(range(n)) def find(self, x): if self.parents[x] == x: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x)...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
195
#include <bits/stdc++.h> using namespace std; const int mxn(1e5 + 10), mxm(4e5 + 10); const long long modl(998244353); int nm, n, m, p, t, k, l, r; int ans; int a[mxn], b[mxn]; int fnd(int x) { return a[x] = x == a[x] ? x : fnd(a[x]); } int main() { ios_base::sync_with_stdio(false); // freopen("in.txt", "r", stdin...
#include <bits/stdc++.h> using namespace std; const int mxn(1e5 + 10), mxm(4e5 + 10); const long long modl(998244353); int nm, n, m, p, t, k, l, r; int ans; int a[mxn], b[mxn]; int fnd(int x) { return a[x] = x == a[x] ? x : fnd(a[x]); } int main() { ios_base::sync_with_stdio(false); // freopen("in.txt", "r", stdin...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22]]
1
204
N, M = map(int, input().split()) 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] d...
N, M = map(int, input().split()) 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] d...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
407
import sys #UnionFindTreeクラスの定義 class UnionFind(): #クラスコンストラクタ #selfはインスタンス自身 def __init__(self, n): #親ノードを-1に初期化する self.parents = [-1] * n #根を探す(再帰関数) def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self...
import sys #UnionFindTreeクラスの定義 class UnionFind(): #クラスコンストラクタ #selfはインスタンス自身 def __init__(self, n): #親ノードを-1に初期化する self.parents = [-1] * n #根を探す(再帰関数) def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
259
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll bfs(vector<vector<ll>> &a, ll x, vector<ll> &vst) { // cout<<x<<endl; ll i, s = 0; // if(vst[x]==1) // return 0; vst[x] = 1; // for(i=1;i<a.size();i++) // cout<<vst[i]<<" "; // cout<<endl; // for(i=0;i<a[x].size();i++) /...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll bfs(vector<vector<ll>> &a, ll x, vector<ll> &vst) { // cout<<x<<endl; ll i, s = 0; // if(vst[x]==1) // return 0; vst[x] = 1; // for(i=1;i<a.size();i++) // cout<<vst[i]<<" "; // cout<<endl; // for(i=0;i<a[x].size();i++) /...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
270
class UnionFind(): # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): # ノードxのrootノードを見つける if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) ...
class UnionFind(): # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): # ノードxのrootノードを見つける if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) ...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
389
#include <bits/stdc++.h> using namespace std; #define ll long long int vector<int> adj[1000001]; bool vis[1000001]; void dfs(int n) { vis[n] = true; for (int a : adj[n]) { if (vis[a] == 0) dfs(a); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, e; cin >> n >> e; for (i...
#include <bits/stdc++.h> using namespace std; #define ll long long int vector<int> adj[1000001]; bool vis[1000001]; void dfs(int n) { vis[n] = true; for (int a : adj[n]) { if (vis[a] == 0) dfs(a); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, e; cin >> n >> e; for (i...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
215
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化 for (int i = 0; i < N; i++) par[i] =...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化 for (int i = 0; i < N; i++) par[i] =...
[["-", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 17, 72]]
1
348
N,M = gets.split.map(&:to_i) UF = [-1]*(N+1) F = lambda{|a| next UF[a]<0 ? a : UF[a]=F[UF[a]] } U = lambda{|ab| a,b = ab.split.map(&:to_i).map(&F) a,b = b,a unless UF[a]<UF[b] UF[a] += UF[b] UF[b] = a } $<.each(&U) p UF.count{|g| g<0 }-2
N,M = gets.split.map(&:to_i) UF = [-1]*(N+1) F = lambda{|a| next UF[a]<0 ? a : UF[a]=F[UF[a]] } U = lambda{|ab| a,b = ab.split.map(&:to_i).map(&F) next if a == b a,b = b,a unless UF[a]<UF[b] UF[a] += UF[b] UF[b] = a } $<.each(&U) p UF.count{|g| g<0 }-2
[["+", 196, 196, 8, 734, 0, 751, 8, 746, 0, 746], ["+", 12, 652, 196, 196, 8, 734, 0, 751, 0, 121], ["+", 196, 196, 8, 734, 0, 751, 15, 738, 17, 60], ["+", 196, 196, 8, 734, 0, 751, 15, 738, 12, 22], ["+", 8, 734, 0, 745, 8, 662, 31, 761, 0, 22]]
4
135
''' Created on 2020/09/26 @author: harurun ''' #UnionFind(要素数)で初期化 class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n #parents 各要素の親番号を格納するリストを返す #要素xが属するグループを返す def find(self, x): if self.parents[x] < 0: return x else: ...
''' Created on 2020/09/26 @author: harurun ''' #UnionFind(要素数)で初期化 class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n #parents 各要素の親番号を格納するリストを返す #要素xが属するグループを返す def find(self, x): if self.parents[x] < 0: return x else: ...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
446
//#fuccccc #include <bits/stdc++.h> #define TASK "" #define inpf freopen(TASK ".inp", "r", stdin) #define outf freopen(TASK ".out", "w", stdout) #define ll long long #define db double #define F first #define S second #define maxn 1000005 #define MP make_pair #define PB push_back using namespace std; int n, m, tr[maxn];...
//#fuccccc #include <bits/stdc++.h> #define TASK "" #define inpf freopen(TASK ".inp", "r", stdin) #define outf freopen(TASK ".out", "w", stdout) #define ll long long #define db double #define F first #define S second #define maxn 1000005 #define MP make_pair #define PB push_back using namespace std; int n, m, tr[maxn];...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
197
#include <iostream> #include <set> #include <string> #include <vector> using namespace std; #define debug(var) \ do { \ std::cout << #var << " : "; ...
#include <iostream> #include <set> #include <string> #include <vector> using namespace std; #define debug(var) \ do { \ std::cout << #var << " : "; ...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
702
import math n, M= map(int,input().split()) #AB=[] #N = int(input()) #C = input() parents = [-1] * n def find( x): if parents[x] < 0: return x else: parents[x] = find(parents[x]) return parents[x] def union(x, y): x = find(x) y = find(y) if x == y: return if p...
import math n, M= map(int,input().split()) #AB=[] #N = int(input()) #C = input() parents = [-1] * n def find( x): if parents[x] < 0: return x else: parents[x] = find(parents[x]) return parents[x] def union(x, y): x = find(x) y = find(y) if x == y: return if p...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
317
#n, m, q = map(int, input().split()) #List = list(map(int, input().split())) #req = [list(map(int, input().split())) for _ in range(q)] #t = t[:-1] #print(ans[j], end = "") 改行無しで出力 #[0]*n #sort = sorted(a)[::-1] 降順 #if l[i] == l[j]: continue n, m = map(int, input().split()) req = [list(map(int, input().split())) for _ ...
#n, m, q = map(int, input().split()) #List = list(map(int, input().split())) #req = [list(map(int, input().split())) for _ in range(q)] #t = t[:-1] #print(ans[j], end = "") 改行無しで出力 #[0]*n #sort = sorted(a)[::-1] 降順 #if l[i] == l[j]: continue n, m = map(int, input().split()) req = [list(map(int, input().split())) for _ ...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
429
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #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, si...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #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, si...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
267
N, M = map(int, input().split()) 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] d...
N, M = map(int, input().split()) 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] d...
[["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 12, 612]]
5
402
# coding:UTF-8 import sys from math import factorial MOD = 10 ** 9 + 7 INF = float('inf') # ユニオンファインド木 class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n self.rank = [0] * n def find(self, x): if self.parents[x] < 0: return x else: ...
# coding:UTF-8 import sys from math import factorial MOD = 10 ** 9 + 7 INF = float('inf') # ユニオンファインド木 class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n self.rank = [0] * n def find(self, x): if self.parents[x] < 0: return x else: ...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
372
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define IOS \ ios ::sync_with_stdio(false); \ cin.tie(0); ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define IOS \ ios ::sync_with_stdio(false); \ cin.tie(0); ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
592
#include <bits/stdc++.h> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //--------...
#include <bits/stdc++.h> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //--------...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
1,489
#include <bits/stdc++.h> using namespace std; typedef long long ll; using pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < n; i++) #define rrep(i, m, n) for (ll i = m; i > n; i--) #define Rep(i, m, n) for (ll i = m; i < n; i++) #define all(vec) vec.begin(), vec.end() #define lmax(x, y) max<ll>(x, y) #define lmi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; using pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < n; i++) #define rrep(i, m, n) for (ll i = m; i > n; i--) #define Rep(i, m, n) for (ll i = m; i < n; i++) #define all(vec) vec.begin(), vec.end() #define lmax(x, y) max<ll>(x, y) #define lmi...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
700
from collections import defaultdict from collections import deque from collections import Counter import math import itertools def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() class UnionFind(): def __...
from collections import defaultdict from collections import deque from collections import Counter import math import itertools def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() class UnionFind(): def __...
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
456
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; const int mx = 2e5 + 5; int n, m, vis[mx]; vector<int> g[mx]; void dfs(int u) { vis[u] = 1; for (int v : g[u]) if (!vis[v]) dfs(v); } int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.t...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; const int mx = 2e5 + 5; int n, m, vis[mx]; vector<int> g[mx]; void dfs(int u) { vis[u] = 1; for (int v : g[u]) if (!vis[v]) dfs(v); } int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.t...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
204
N, M = map(int, input().split()) Pajew = [i for i in range(n)] import sys sys.setrecursionlimit(1000000) def find(x, Pajew): if Pajew[x] == x: return x else: a = find(Pajew[x], Pajew) Pajew[x] =a return a def unite(x, y): x = find(x, Pajew) y = find(y, Pajew) if x !...
N, M = map(int, input().split()) Pajew = [i for i in range(N)] import sys sys.setrecursionlimit(1000000) def find(x, Pajew): if Pajew[x] == x: return x else: a = find(Pajew[x], Pajew) Pajew[x] =a return a def unite(x, y): x = find(x, Pajew) y = find(y, Pajew) if x !...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]]
5
172
#include <bits/stdc++.h> using namespace std; // (setq-default c-basic-offset 2) // UnionFind // coding: https://youtu.be/TdR816rqc3s?t=726 // comment: https://youtu.be/TdR816rqc3s?t=6822 struct UnionFind { vector<int> d; UnionFind(int n = 0) : d(n, -1) {} int find(int x) { if (d[x] < 0) return x; ...
#include <bits/stdc++.h> using namespace std; // (setq-default c-basic-offset 2) // UnionFind // coding: https://youtu.be/TdR816rqc3s?t=726 // comment: https://youtu.be/TdR816rqc3s?t=6822 struct UnionFind { vector<int> d; UnionFind(int n = 0) : d(n, -1) {} int find(int x) { if (d[x] < 0) return x; ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
296
package main import ( "bufio" "fmt" "os" "strconv" ) func main() { var n,m int fmt.Scan(&n, &m) sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) uf := newUnionFind(n+1) for i := 0; i < m; i++ { sc.Scan() a, _ := strconv.Atoi(sc.Text()) sc.Scan() b, _ := strconv.Atoi(sc.Text()) uf.unite(a,...
package main import ( "bufio" "fmt" "os" "strconv" ) func main() { var n,m int fmt.Scan(&n, &m) sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) uf := newUnionFind(n+10) for i := 0; i < m; i++ { sc.Scan() a, _ := strconv.Atoi(sc.Text()) sc.Scan() b, _ := strconv.Atoi(sc.Text()) uf.unite(a...
[["-", 12, 432, 0, 2, 3, 4, 0, 16, 12, 433], ["+", 12, 432, 0, 2, 3, 4, 0, 16, 12, 433], ["-", 0, 7, 0, 430, 10, 431, 12, 432, 0, 433], ["+", 0, 7, 0, 430, 10, 431, 12, 432, 0, 433]]
7
440
#include <bits/stdc++.h> #define ll long long #define deb(x) cout << #x << " " << x << "\n"; using namespace std; void dfs(ll ver, unordered_map<int, vector<int>> &g, vector<int> &visited) { visited[ver] = 1; for (auto x : g[ver]) { if (visited[x] == -1) { dfs(x, g, visited); } } } void solve() {...
#include <bits/stdc++.h> #define ll long long #define deb(x) cout << #x << " " << x << "\n"; using namespace std; void dfs(ll ver, unordered_map<int, vector<int>> &g, vector<int> &visited) { visited[ver] = 1; for (auto x : g[ver]) { if (visited[x] == -1) { dfs(x, g, visited); } } } void solve() {...
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
246
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, s, n) for (int i = (s); i < (n); ++i) #define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define len(x) (int)(x).size() #define dup(x, y) (((x) + (y)-1) / (y)) #define ...
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, s, n) for (int i = (s); i < (n); ++i) #define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define len(x) (int)(x).size() #define dup(x, y) (((x) + (y)-1) / (y)) #define ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
410
def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] def same(x, y): return find(x) == find(y) def unite(x, y): x = find(x) y = find(y) if x == y: return if par[x] > par[y]: x, y = y, x par[x] += par[y] par[y] = x ...
def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] def same(x, y): return find(x) == find(y) def unite(x, y): x = find(x) y = find(y) if x == y: return if par[x] > par[y]: x, y = y, x par[x] += par[y] par[y] = x ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 8, 196, 0, 57, 15, 666, 0, 664, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 664, 28, 612]]
5
201
import collections sys.setrecursionlimit(10**6) def dfs(visited,v,adj): visited[v]=True for i in adj[v]: if not visited[i]: dfs(visited,i,adj) adj=collections.defaultdict(list) n,m=map(int,input().split()) visited=[False]*n for i in range(m): u,v=map(int,input().split()) adj[u...
import collections import sys sys.setrecursionlimit(10**6) def dfs(visited,v,adj): visited[v]=True for i in adj[v]: if not visited[i]: dfs(visited,i,adj) adj=collections.defaultdict(list) n,m=map(int,input().split()) visited=[False]*n for i in range(m): u,v=map(int,input().split())...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
165
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, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
416
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, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
457
/* Name: Author: xiaruize Date: */ #pragma GCC optimize(2) #include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define MOD 1000000007 #define ALL(a) (a).begin(), (a).end() #define forn(i, n) for (int i = 0; i < int(n); i++) #define form(i, j, n) for (int i = int(j); i <=...
/* Name: Author: xiaruize Date: */ #pragma GCC optimize(2) #include <bits/stdc++.h> using namespace std; #define ull unsigned long long #define MOD 1000000007 #define ALL(a) (a).begin(), (a).end() #define forn(i, n) for (int i = 0; i < int(n); i++) #define form(i, j, n) for (int i = int(j); i <=...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
250
import math import collections import itertools import copy def YesNo(Bool): if(Bool): print("YES") else: print("NO") return class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: ...
import math import collections import itertools import copy def YesNo(Bool): if(Bool): print("YES") else: print("NO") return class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: ...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
470
/// Bismillahir Rahmanir Rahim /// ALLAHU AKBAR #include <bits/stdc++.h> #define flash() \ ios::sync_with_stdio(0); \ cin.tie(0); \ co...
/// Bismillahir Rahmanir Rahim /// ALLAHU AKBAR #include <bits/stdc++.h> #define flash() \ ios::sync_with_stdio(0); \ cin.tie(0); \ co...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
1,186
#include <bits/stdc++.h> //brute force forever using namespace std; #define ll long long int #define pb push_back #define pob pop_back #define pii pair<int, int> #define pll pair<ll, ll> #define FOR(i, n) for (int i = 0; i < n; i++) #define FORE(i, a, b) for (int i = a; i <= b; i++) #define RFOR(i, n) for (int i = n; i...
#include <bits/stdc++.h> //brute force forever using namespace std; #define ll long long int #define pb push_back #define pob pop_back #define pii pair<int, int> #define pll pair<ll, ll> #define FOR(i, n) for (int i = 0; i < n; i++) #define FORE(i, a, b) for (int i = a; i <= b; i++) #define RFOR(i, n) for (int i = n; i...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
451
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <set> #include <stack> using namespace std; #define N 100009 #define LL long long #define INF 0x3f3f3f3f #define mymin(x, y) (x >= y ? y : x) #define mymax(x, y) (x >= y ? x : y) int pre[N]; int unio...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <set> #include <stack> using namespace std; #define N 1000009 #define LL long long #define INF 0x3f3f3f3f #define mymin(x, y) (x >= y ? y : x) #define mymax(x, y) (x >= y ? x : y) int pre[N]; int uni...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
224
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools #include <bits/stdc++.h> // #include "atcoder/all" using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18) + 7; template <typename T> bool chmin(T &x, T y) { if (x > y) { x = y; return true; } ...
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools #include <bits/stdc++.h> // #include "atcoder/all" using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18) + 7; template <typename T> bool chmin(T &x, T y) { if (x > y) { x = y; return true; } ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
474
#include <bits/stdc++.h> using namespace std; #define pb push_back #define in insert #define PI 3.1415926535897932384626433832795 #define F first #define S second #define aLL(str) (str).begin(), (str).end() #define IOS \ ios::sync_with_stdio(0); ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define in insert #define PI 3.1415926535897932384626433832795 #define F first #define S second #define aLL(str) (str).begin(), (str).end() #define IOS \ ios::sync_with_stdio(0); ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
324
#include <bits/stdc++.h> using namespace std; #define forn(i, n) for (int i = 0; i < n; i++) #define for1(i, n) for (int i = 1; i <= n; i++) #define PrintArray(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i]...
#include <bits/stdc++.h> using namespace std; #define forn(i, n) for (int i = 0; i < n; i++) #define for1(i, n) for (int i = 1; i <= n; i++) #define PrintArray(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i]...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
799
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 6; int f[maxn], ans; int find(int x) { if (f[x] == x) return x; else return f[x] = find(f[x]); } int main() { int a, b; cin >> a >> b; for (int i = 0; i < a; i++) { f[i] = i; } for (int i = 0; i < b; i++) { int u, v; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 6; int f[maxn], ans; int find(int x) { if (f[x] == x) return x; else return f[x] = find(f[x]); } int main() { int a, b; cin >> a >> b; for (int i = 0; i < a; i++) { f[i] = i; } for (int i = 0; i < b; i++) { int u, v; ...
[["-", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 72]]
1
171
class UnionFind(): def __init__(self,n): self.n = n self.parents = [-1] * (n+1) def find(self, x): if self.parents[x] < 0: return x 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 == y: ...
class UnionFind(): def __init__(self,n): self.n = n self.parents = [-1] * (n+1) def find(self, x): if self.parents[x] < 0: return x 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 == y: ...
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]]
5
341
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #define...
#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #define...
[["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 0, 57, 15, 339, 51, 91, 28, 23, 0, 24], ["+", 51, 91, 28, 23, 0, 2, 3, 4, 0, 25]]
1
551
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i < n; ++i) #define exrep(i, a, b) for (ll i = a; i < b; i++) #define out(x) cout << x << e...
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i < n; ++i) #define exrep(i, a, b) for (ll i = a; i < b; i++) #define out(x) cout << x << e...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
711
import java.lang.reflect.Array; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Main ak = new Main(); ak.solve(sc); } void solve(Scanner in) { int...
import java.lang.reflect.Array; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Main ak = new Main(); ak.solve(sc); } void solve(Scanner in) { int...
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
3
401
#include <algorithm> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <unordered_map> #include <unordere...
#include <algorithm> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <unordered_map> #include <unordere...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 17, 33], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
427
#include <ctype.h> #include <float.h> #include <inttypes.h> #include <limits.h> #include <math.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #ifdef __cplusplus #include <bits/stdc++.h> ...
#include <ctype.h> #include <float.h> #include <inttypes.h> #include <limits.h> #include <math.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #ifdef __cplusplus #include <bits/stdc++.h> ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
0
1,782
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> a(n + 1); for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } vector<bool> used(n, 0); int ans = 0; for (int i = 0; i < n; i++) { if (!us...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> a(n + 1); for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } vector<bool> used(n + 2, 0); int ans = 0; for (int i = 1; i <= n; i++) { if...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
220
#include "bits/stdc++.h" using namespace std; #define PIGRECO 3.141592653589793 #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator...
#include "bits/stdc++.h" using namespace std; #define PIGRECO 3.141592653589793 #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator...
[["-", 0, 356, 0, 42, 0, 2, 3, 4, 0, 22], ["+", 0, 356, 0, 42, 0, 2, 3, 4, 0, 22]]
1
480
#include <iostream> #include <vector> using namespace std; #define MAX 100005 int n, m; bool visited[MAX]; vector<int> graph[MAX]; void DFS(int u) { visited[u] = true; for (int i = 0; i < graph[u].size(); i++) { int v = graph[u][i]; if (!visited[v]) DFS(v); } } int main() { int testcase, u, v, n...
#include <iostream> #include <vector> using namespace std; #define MAX 100005 int n, m; bool visited[MAX]; vector<int> graph[MAX]; void DFS(int u) { visited[u] = true; for (int i = 0; i < graph[u].size(); i++) { int v = graph[u][i]; if (!visited[v]) DFS(v); } } int main() { int testcase, u, v, n...
[["-", 8, 9, 0, 1, 0, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
223
n,m = gets.chomp.split(" ").map(&:to_i); class UnionFind def initialize(size) @rank = Array.new(size, 0) @parent = Array.new(size, &:itself) #@開始はインスタンス変数:オブジェクトが存在する間有効 end def unite(id_x, id_y) x_parent = get_parent(id_x) y_parent = get_parent(id_y) return if x_parent == y_parent ...
n,m = gets.chomp.split(" ").map(&:to_i); class UnionFind def initialize(size) @rank = Array.new(size, 0) @parent = Array.new(size, &:itself) end def unite(id_x, id_y) x_parent = get_parent(id_x) y_parent = get_parent(id_y) return if x_parent == y_parent if @rank[x_parent] > @rank[y_p...
[["+", 12, 652, 196, 196, 8, 734, 0, 738, 17, 33], ["+", 12, 652, 196, 196, 8, 734, 0, 738, 12, 612]]
4
231
f = lambda x: x if p[x]<0 else f(p[x]) N,M = map(int,input().split()) p = [-1]*N for _ in range(M): A,B = map(lambda x:f(int(x)),input().split()) if A==B: continue elif A<B: A,B=B,A p[A] += p[B] p[B] = A print(sum(i<0 for i in p)-1)
f = lambda x: x if p[x]<0 else f(p[x]) N,M = map(int,input().split()) p = [-1]*N for _ in range(M): A,B = map(lambda x:f(int(x)-1),input().split()) if A==B: continue elif A<B: A,B=B,A p[A] += p[B] p[B] = A print(sum(i<0 for i in p)-1)
[["+", 0, 670, 8, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 670, 8, 652, 3, 4, 0, 657, 12, 612]]
5
126
#include <bits/stdc++.h> using namespace std; #define ll long long bool comp(int a, int b) { if (a <= b) return false; return true; } vector<int> arr[100005]; vector<int> visited(100005, 0); void dfs(int i) { visited[i]++; for (auto j : arr[i]) { if (!visited[i]) dfs(j); } } void solve() ...
#include <bits/stdc++.h> using namespace std; #define ll long long bool comp(int a, int b) { if (a <= b) return false; return true; } vector<int> arr[100005]; vector<int> visited(100005, 0); void dfs(int i) { visited[i]++; for (auto j : arr[i]) { if (!visited[j]) { dfs(j); } } } void ...
[["-", 15, 339, 51, 91, 28, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 91, 28, 69, 341, 342, 0, 22], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 46]]
1
216
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; int vis[N]; vector<int> G[N]; void dfs(int n) { vis[n] = 1; for (auto i : G[n]) { if (!vis[i]) dfs(i); } } int main() { int n, M, ans = 0; cin >> n >> M; while (M--) { int u, v; cin >> u >> v; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; int vis[N]; vector<int> G[N]; void dfs(int n) { vis[n] = 1; for (auto i : G[n]) { if (!vis[i]) dfs(i); } } int main() { int n, M, ans = 0; cin >> n >> M; while (M--) { int u, v; cin >> u >> v; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 7, 15, 16, 12, 91, 17, 72], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
175
#include <iostream> #define ll long long using namespace std; ll pre[1000000 + 5]; ll find(ll i) { if (i == pre[i]) return i; return pre[i] = find(pre[i]); } void merge(ll x, ll y) { ll fx = find(x), fy = find(y); if (fx != fy) pre[fx] = fy; } int main() { ll n, m; cin >> n >> m; for (int i = 0; i...
#include <iostream> #define ll long long using namespace std; ll pre[1000000 + 5]; ll find(ll i) { if (i == pre[i]) return i; return pre[i] = find(pre[i]); } void merge(ll x, ll y) { ll fx = find(x), fy = find(y); if (fx != fy) pre[fx] = fy; } int main() { ll n, m; cin >> n >> m; for (int i = 1; i...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
201
n,m = map(int,input().split()) class Unionfind: def __init__(self,n): self.uf = [-1]*n def find(self,x): if self.uf[x] < 0: return x else: self.uf[x] = self.find(self.uf[x]) return self.uf[x] def same(self,x,y): return self.find(...
n,m = map(int,input().split()) class Unionfind: def __init__(self,n): self.uf = [-1]*n def find(self,x): if self.uf[x] < 0: return x else: self.uf[x] = self.find(self.uf[x]) return self.uf[x] def same(self,x,y): return self.find(...
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
291
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define DEBUG 1 using namespace std; constexpr int kMod = 1000000007; typedef long lo...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define DEBUG 1 using namespace std; constexpr int kMod = 1000000007; typedef long lo...
[["-", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 69, 28, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 15, 339, 51, 16, 31, 69, 341, ...
1
326
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define rp(i, k, n) for (int i = k; i < n; i++) using ll = long long; using ld = double; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <clas...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define rp(i, k, n) for (int i = k; i < n; i++) using ll = long long; using ld = double; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <clas...
[["+", 0, 9, 0, 57, 15, 339, 51, 91, 17, 111]]
1
447
import sys from collections import deque N, M = map(int, input().split()) edge = [[] for _ in range(N)] for s in sys.stdin.readlines(): a, b = map(lambda x: int(x) - 1, s.split()) edge[a].append(b) edge[b].append(a) path = [-1] * N cnt = 0 for i in range(N): if path[i] < 0: cnt += 1 q...
import sys from collections import deque N, M = map(int, input().split()) edge = [[] for _ in range(N)] for s in sys.stdin.readlines(): a, b = map(lambda x: int(x) - 1, s.split()) edge[a].append(b) edge[b].append(a) path = [-1] * N cnt = 0 for i in range(N): if path[i] < 0: cnt += 1 q...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
175