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 <bits/stdc++.h> using namespace std; #define ll long long int #define mset(arr, val) memset(arr, val, sizeof(arr)) #define loop(i, a, b) for (ll i = a; i < b; ++i) #define dloop(i, a, b) for (ll i = a; i >= b; --i) #define all(a) a.begin(), a.end() #define lar 1000000007 #define pq priority_queue #define pll p...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define mset(arr, val) memset(arr, val, sizeof(arr)) #define loop(i, a, b) for (ll i = a; i < b; ++i) #define dloop(i, a, b) for (ll i = a; i >= b; --i) #define all(a) a.begin(), a.end() #define lar 1000000007 #define pq priority_queue #define pll p...
[["-", 0, 57, 64, 1, 0, 11, 31, 69, 28, 22], ["+", 0, 57, 64, 1, 0, 11, 31, 69, 28, 22]]
1
402
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define inf 1001001001 #define mod 1000000007 #define mod2 998244353 #define pi acos(-1) #define all(v) v.begin(), v.end() int dx[4] = {0, -1, 0, 1}; int dy[4] = {-1, 0, 1, 0}; ll gcd(ll a, ll b) {...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define inf 1001001001 #define mod 1000000007 #define mod2 998244353 #define pi acos(-1) #define all(v) v.begin(), v.end() int dx[4] = {0, -1, 0, 1}; int dy[4] = {-1, 0, 1, 0}; ll gcd(ll a, ll b) {...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
479
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long int ll; typedef unsigned long long int ull; typedef tree<int, null_type, less<int>, rb_tree_tag, ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long int ll; typedef unsigned long long int ull; typedef tree<int, null_type, less<int>, rb_tree_tag, ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
429
from collections import deque n, m = map(int, input().split()) graph = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) li = [] seen = [False]*n for i in range(n): if seen[i]: continue q = deque([i]) seen[i] = True ...
from collections import deque n, m = map(int, input().split()) graph = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) li = [] seen = [False]*n for i in range(n): if seen[i]: continue q = deque([i]) seen[i] = True ...
[["+", 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
173
def find(x): while x!=p[x]: x=p[x] return x def union(a,b): x=find(a) global con y=find(b) if x!=y: p[y]=p[x]=min(x,y);con-=1 r[min(x,y)]+=r[max(x,y)];con=max(con,r[min(x,y)]) n,m=map(int,input().split()) p=[i for i in range(n+1)] con=1 r=[1]*(n+1) for i in range(m): u,v=map(int,input().split()) union(...
def find(x): while x!=p[x]: x=p[x] return x def union(a,b): x=find(a) global con y=find(b) if x!=y: p[y]=p[x]=min(x,y);con-=1 r[min(x,y)]+=r[max(x,y)];con=max(con,r[min(x,y)]) n,m=map(int,input().split()) p=[i for i in range(n+1)] con=1 r=[1]*(n+1) for i in range(m): u,v=map(int,input().split()) union(...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
183
#include <bits/stdc++.h> using namespace std; double pi = 3.14159265358979323846264338; int sum; int arr[200001]; vector<int> arr2[200001]; map<pair<int, int>, bool> ma; void dfs(int a) { // cout<<a<<" "<<sum<<endl; arr[a]++; sum++; for (int b : arr2[a]) { if (arr[b]) continue; dfs(b); } } int...
#include <bits/stdc++.h> using namespace std; double pi = 3.14159265358979323846264338; int sum; int arr[200001]; vector<int> arr2[200001]; map<pair<int, int>, bool> ma; void dfs(int a) { // cout<<a<<" "<<sum<<endl; arr[a]++; sum++; // cout<<a<<" "<<arr2[a].size()<<endl; for (int b : arr2[a]) { // cout<...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
287
#include <bits/stdc++.h> #define boost \ ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); //#define int long long #define M ...
#include <bits/stdc++.h> #define boost \ ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); //#define int long long #define M ...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
285
#include <bits/stdc++.h> using namespace std; #define int long long #define PB push_back #define ALL(x) (x).begin(), (x).end() #define ALLR(x) (x).rbegin(), (x).rend() #define MP make_pair template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_stri...
#include <bits/stdc++.h> using namespace std; #define int long long #define PB push_back #define ALL(x) (x).begin(), (x).end() #define ALLR(x) (x).rbegin(), (x).rend() #define MP make_pair template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_stri...
[["-", 0, 1, 0, 2, 3, 4, 0, 118, 119, 120], ["+", 0, 1, 0, 2, 3, 4, 0, 118, 119, 120]]
1
1,621
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define int int64_t #define fio \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); ...
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define int int64_t #define fio \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
271
#include <bits/stdc++.h> using namespace std; struct unin { vector<int> pr, sz; unin(int n) { pr.resize(n + 1); sz = pr; for (int i = 0; i <= n; i++) { sz[i] = 1; pr[i] = i; } } int getrt(int x) { if (pr[x] == x) return x; return getrt(pr[x]); } int cnct(int x, in...
#include <bits/stdc++.h> using namespace std; struct unin { vector<int> pr, sz; unin(int n) { pr.resize(n + 1); sz = pr; for (int i = 0; i <= n; i++) { sz[i] = 1; pr[i] = i; } } int getrt(int x) { if (pr[x] == x) return x; return getrt(pr[x]); } int cnct(int x, in...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
309
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define RREP(...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define RREP(...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
497
/* vrrtll==???>;::::~~~~~~......`.`````````````````````...-?777!_.._?7u,~~~::::;>>??=lllttrrzu rtll==??>>;::::~~~~......`.`````````````````` ..J77!`````````...`..._T,~~~~:::;;>??==lttrrv tll=??>>;:::~~~~......``````````````````..J7^ ` `` ` `` .,```````...._4,.~~~::;;>>?===lttr l=???>;;::~~~......`````HTSu,.`` `..J7! ...
/* vrrtll==???>;::::~~~~~~......`.`````````````````````...-?777!_.._?7u,~~~::::;>>??=lllttrrzu rtll==??>>;::::~~~~......`.`````````````````` ..J77!`````````...`..._T,~~~~:::;;>??==lttrrv tll=??>>;:::~~~~......``````````````````..J7^ ` `` ` `` .,```````...._4,.~~~::;;>>?===lttr l=???>;;::~~~......`````HTSu,.`` `..J7! ...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
1,073
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define fastIO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0)...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define fastIO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0)...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
739
#include <bits/stdc++.h> #ifndef M_PI #define M_PI 3.14159265358979 #endif #define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI) #define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360) using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; typedef pair<ll, ll> pll; typedef pair<int, int> ...
#include <bits/stdc++.h> #ifndef M_PI #define M_PI 3.14159265358979 #endif #define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI) #define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360) using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; typedef pair<ll, ll> pll; typedef pair<int, int> ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 70], ["-", 0, 27, 28, 69, 341, 342, 0, 69, 28, 22], ["+", 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]...
1
466
#include <bits/stdc++.h> using namespace std; const int SZ = 2 * 1e5 + 1; vector<int> parent(SZ, -1); int root(int x) { return parent[x] == -1 ? x : root(parent[x]); } void merge(int a, int b) { int x = root(a); int y = root(b); if (x == y) return; if (x < y) { parent[y] = x; } else { parent[x...
#include <bits/stdc++.h> using namespace std; const int SZ = 2 * 1e5 + 1; vector<int> parent(SZ, -1); int root(int x) { return parent[x] == -1 ? x : root(parent[x]); } void merge(int a, int b) { int x = root(a); int y = root(b); if (x == y) return; if (x < y) { parent[y] = x; } else { parent[x...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
328
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for...
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
349
// Problem: D - Friends // Contest: AtCoder - AtCoder Beginner Contest 177 // URL: https://atcoder.jp/contests/abc177/tasks/abc177_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> using namespace std; typedef long long LL; #defin...
// Problem: D - Friends // Contest: AtCoder - AtCoder Beginner Contest 177 // URL: https://atcoder.jp/contests/abc177/tasks/abc177_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> using namespace std; typedef long long LL; #defin...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
395
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
[["-", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]]
1
756
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; // Union-Find Disjoint Sets Library written in OOP manner, using both path // compression and union by rank heuristics class UnionFind { // OOP style private: vi p, rank, setSize; // remember: vi is vector<int> int numSets; public: UnionFind...
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; // Union-Find Disjoint Sets Library written in OOP manner, using both path // compression and union by rank heuristics class UnionFind { // OOP style private: vi p, rank, setSize; // remember: vi is vector<int> int numSets; public: UnionFind...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
405
N, M = map(int, input().split()) connect = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) a, b = a - 1, b - 1 connect[a].append(b) connect[b].append(a) #print(connect) ans = 0 used = [0] * N for i in range(N): if used[i] == 0: used[i] = 1 ans2 = 1 queue = [i] ...
N, M = map(int, input().split()) connect = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) a, b = a - 1, b - 1 connect[a].append(b) connect[b].append(a) #print(connect) ans = 0 used = [0] * N for i in range(N): if used[i] == 0: used[i] = 1 ans2 = 1 queue = [i] ...
[["-", 0, 52, 8, 196, 0, 7, 12, 206, 206, 22], ["+", 0, 52, 8, 196, 0, 7, 12, 206, 206, 22]]
5
176
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int p[N], d[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x]; } int main() { cin.tie(0); ios::sync_with_stdio(0); int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { d[i] = 1; p[i] = i; } i...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int p[N], d[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x]; } int main() { cin.tie(0); ios::sync_with_stdio(0); int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { d[i] = 1; p[i] = i; } i...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
227
n,m=map(int,input().split()) p=[(i,1)for i in range(n)] def find(i): if p[i][0]==i:return i else: c=find(p[i][0]) p[i]=(c,0) return c def union(i,j): pi=find(i) pj=find(j) if not pi==pj: if p[pi][1]>p[pj][1]: p[pi]=(pi,p[pi][1]+p[pj][1]) p[pj]=(pi,0) else: p[pj]=(pj,p[pi]...
n,m=map(int,input().split()) p=[(i,1)for i in range(n)] def find(i): if p[i][0]==i:return i else: c=find(p[i][0]) p[i]=(c,0) return c def union(i,j): pi=find(i) pj=find(j) if not pi==pj: if p[pi][1]>p[pj][1]: p[pi]=(pi,p[pi][1]+p[pj][1]) p[pj]=(pi,0) else: p[pj]=(pj,p[pi]...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
260
#include <iostream> #include <unordered_map> #include <vector> using namespace std; int find(vector<int> &fa, int x) { return fa[x] == x ? x : fa[x] = find(fa, fa[x]); } void uni(vector<int> &fa, int x, int y) { int px = find(fa, x); int py = find(fa, y); if (px == py) return; fa[x] = y; } int main() {...
#include <iostream> #include <unordered_map> #include <vector> using namespace std; int find(vector<int> &fa, int x) { return fa[x] == x ? x : fa[x] = find(fa, fa[x]); } void uni(vector<int> &fa, int x, int y) { int px = find(fa, x); int py = find(fa, y); if (px == py) return; fa[px] = py; } int main()...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]]
1
261
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define inf 1e15 #define N 300005 string s; ll n, m, x, y, d, k; ll a[N]; ll parent[N]; ll siz[N]; int find(int g) { if (parent[g] != g) { parent[g] = find(parent[g]); } return g; } int main() { ios_ba...
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define inf 1e15 #define N 300005 string s; ll n, m, x, y, d, k; ll a[N]; ll parent[N]; ll siz[N]; int find(int g) { if (parent[g] != g) { parent[g] = find(parent[g]); } return parent[g]; } int main() { ...
[["+", 0, 14, 8, 9, 0, 37, 0, 69, 28, 22], ["+", 8, 9, 0, 37, 0, 69, 341, 342, 0, 70], ["+", 8, 9, 0, 37, 0, 69, 341, 342, 0, 73]]
1
286
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define overload4(_1, _2, _3, _4, name, ...) name #define overload3(_1, _2, _3, name, ...) name #define rep1(n) for (ll i = 0; i < n; ++i) #define rep2(i, n) for (ll i = 0; i < n; ++i) #define rep...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define overload4(_1, _2, _3, _4, name, ...) name #define overload3(_1, _2, _3, name, ...) name #define rep1(n) for (ll i = 0; i < n; ++i) #define rep2(i, n) for (ll i = 0; i < n; ++i) #define rep...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
434
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i < b; ++i) #define ALL(vec) vec.begin(), vec.end() #define rALL(vec) vec.rbegin(), vec.rend() using namespace std; using ll = long long; // ------------------------------ int main() { int N, M; cin >> N >> ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i < b; ++i) #define ALL(vec) vec.begin(), vec.end() #define rALL(vec) vec.rbegin(), vec.rend() using namespace std; using ll = long long; // ------------------------------ int main() { int N, M; cin >> N >> ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22], ["+", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22]]
1
341
#include <bits/stdc++.h> using namespace std; #define lli long long int #define rep(i, n) \ ; \ for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) ...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define rep(i, n) \ ; \ for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) ...
[["-", 28, 69, 341, 342, 0, 69, 28, 118, 119, 120], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 28, 69, 341, 342, 0, 2, 63, 118, 119, 120], ["+", 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
350
#include <bits/stdc++.h> #include <cstdio> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; using ll = long long; ll find(ll x, vector<ll> &par) { if (par.at(x) == x) { return x; } else { return par.at(x) = find(par.at(x), par); } } int main() { ll N, M; cin >> N...
#include <bits/stdc++.h> #include <cstdio> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; using ll = long long; ll find(ll x, vector<ll> &par) { if (par.at(x) == x) { return x; } else { return par.at(x) = find(par.at(x), par); } } int main() { ll N, M; cin >> N...
[["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13]]
1
423
import sys N, M = map(int, input().split()) sys.setrecursionlimit(M+N) v_neighbor = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) v_neighbor[a-1].append(b-1) v_neighbor[b-1].append(a-1) v_visit = [False for _ in range(N)] def search(n): count = 0 for n_ in set(v_ne...
import sys N, M = map(int, input().split()) sys.setrecursionlimit(10**7) v_neighbor = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) v_neighbor[a-1].append(b-1) v_neighbor[b-1].append(a-1) v_visit = [False for _ in range(N)] def search(n): count = 0 for n_ in set(v_...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 578], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
181
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(v) ((int)(v).size()) #define all(v) (v).begin(), (v).end() typedef pair<int, int> pii; const int mod = (int)1000000007; const int inf = (int)2e18; int par[200010], Rank[200010]; int find(int a) { if (par[a] < 0) return a; int x = fi...
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(v) ((int)(v).size()) #define all(v) (v).begin(), (v).end() typedef pair<int, int> pii; const int mod = (int)1000000007; const int inf = (int)2e18; int par[200010], Rank[200010]; int find(int a) { if (par[a] < 0) return a; int x = fi...
[["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
497
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define l(i, a, b) for (auto i = a; i < b; i++) #define lr(i, a, b) for (auto i = a; i >= b; i--) #define ll long long #define lli long long int #define ld long double #define vec vector<int> #define mii map<ll, ll> #define vl vector<long long> #define se set<long ...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define l(i, a, b) for (auto i = a; i < b; i++) #define lr(i, a, b) for (auto i = a; i >= b; i--) #define ll long long #define lli long long int #define ld long double #define vec vector<int> #define mii map<ll, ll> #define vl vector<long long> #define se set<long ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
358
from collections import defaultdict from collections import deque def main(): N, M = map(int, input().split()) A = [0] * M B = [0] * M for i in range(M): a, b = map(int, input().split()) A[i] = a - 1 B[i] = b - 1 friends = defaultdict(set) for i in range(M): ...
from collections import defaultdict from collections import deque def main(): N, M = map(int, input().split()) A = [0] * M B = [0] * M for i in range(M): a, b = map(int, input().split()) A[i] = a - 1 B[i] = b - 1 friends = defaultdict(set) for i in range(M): ...
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 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
287
#include <bits/stdc++.h> using namespace std; #define ll long long const int maxn = 2e5 + 10; int par[maxn]; int rank1[maxn]; int siz[maxn]; void f(int n) //初始化 { for (int i = 0; i < n; i++) { par[i] = i; rank1[i] = 0; siz[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } else { r...
#include <bits/stdc++.h> using namespace std; #define ll long long const int maxn = 2e5 + 10; int par[maxn]; int rank1[maxn]; int siz[maxn]; void f(int n) //初始化 { for (int i = 1; i <= n; i++) { par[i] = i; rank1[i] = 0; siz[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } else { ...
[["-", 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
333
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iterator> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; struct Node { int pos; int flag; std::vector<int> connects; }; Node nodes[200010]; int n, m; i...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iterator> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; struct Node { int pos; int flag; std::vector<int> connects; }; Node nodes[200010]; int n, m; i...
[["-", 51, 69, 28, 118, 28, 69, 341, 342, 0, 22], ["+", 51, 69, 28, 118, 28, 69, 341, 342, 0, 22]]
1
416
//ÈÓã Çááå æáÇ Íæá æáÇ ÞæÉ ÅáÇ //ÈÇááå #include <bits/stdc++.h> #define ll long long #define fir first #define sec second #define pb push_back #define ins insert #define be begin #define en end #define fast ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL) using namespace std; const int ...
//ÈÓã Çááå æáÇ Íæá æáÇ ÞæÉ ÅáÇ //ÈÇááå #include <bits/stdc++.h> #define ll long long #define fir first #define sec second #define pb push_back #define ins insert #define be begin #define en end #define fast ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL) using namespace std; const int ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
305
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll LINF = 1e18; const int INF = 1e9; #define rep(i, n) for (int i = 0; i < (int)(n); i++) struct UnionFind { vector<int> par; UnionFind(int N) : par(N) { rep(i, N) par[i] = i; } int root(int x) { if (par[x] == x) return x; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll LINF = 1e18; const int INF = 1e9; #define rep(i, n) for (int i = 0; i < (int)(n); i++) struct UnionFind { vector<int> par; UnionFind(int N) : par(N) { rep(i, N) par[i] = i; } int root(int x) { if (par[x] == x) return x; ...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 72], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13]]
1
284
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; typedef int64_t ll; const int MAX_N = 200000; int par[MAX_N]; int Rank[MAX_N]; void init(int n) { for (int i = 0; i < n; i++)...
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; typedef int64_t ll; const int MAX_N = 300000; int par[MAX_N]; int Rank[MAX_N]; void init(int n) { for (int i = 0; i < n; i++)...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 27, 28, 2, 3, 4, 0, 69, 28, 22], ["-", 28, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["+", 0, 27, 28, 2, 3, 4, 0, 2, 63, 22], ["+", 28, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["-", 28, 2, 3, 4, 0, 69, 341, 342, 0, 73], ["+", 28, 2, 3, 4, ...
1
380
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define For(i, a, b) for (long long i = a; i < b; i++) #define pb push_back using namespace std; typedef long long ll; ll power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) { res = (res * x) % p; ...
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define For(i, a, b) for (long long i = a; i < b; i++) #define pb push_back using namespace std; typedef long long ll; ll power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) { res = (res * x) % p; ...
[["-", 0, 52, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 52, 8, 9, 0, 7, 10, 43, 39, 78], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 0, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
499
#include <bits/stdc++.h> using namespace std; #define ll long long vector<ll> P; void init(ll N) { for (ll i = 1; i <= N; ++i) P[i] = i; } ll root(ll a) { if (P[a] == a) return a; return (P[a] = root(P[a])); } bool is_same_set(int a, int b) { return root(a) == root(b); } void unite(ll a, ll b) { P[r...
#include <bits/stdc++.h> using namespace std; #define ll long long vector<ll> P; void init(ll N) { for (ll i = 1; i <= N; ++i) P[i] = i; } ll root(ll a) { if (P[a] == a) return a; return (P[a] = root(P[a])); } bool is_same_set(int a, int b) { return root(a) == root(b); } void unite(ll a, ll b) { P[r...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
304
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double lf; typedef pair<int, int> ii; typedef pair<ii, int> iii; #define REP(i, n) for (int i = 0; i < n; i++) #define REP1(i, n) for (int i = 1; i <= n; i++) #define RST(i, n) memset(i, n, sizeof i) #define SZ(a) (int)a.size() #define ALL(a) a...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double lf; typedef pair<int, int> ii; typedef pair<ii, int> iii; #define REP(i, n) for (int i = 0; i < n; i++) #define REP1(i, n) for (int i = 1; i <= n; i++) #define RST(i, n) memset(i, n, sizeof i) #define SZ(a) (int)a.size() #define ALL(a) a...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
750
import sys input = sys.stdin.readline N, M = map(int, input().split()) class UnionFind(): def __init__(self, n): self.n = n self.root = [-1] * (n + 1) self.rnk = [0] * (n + 1) def Find_Root(self, x): if self.root[x] < 0: return x else: self.root[x] = self.Find_Root(self.root[x]) ...
import sys input = sys.stdin.readline N, M = map(int, input().split()) class UnionFind(): def __init__(self, n): self.n = n self.root = [-1] * (n + 1) self.rnk = [0] * (n + 1) def Find_Root(self, x): if self.root[x] < 0: return x else: self.root[x] = self.Find_Root(self.root[x]) ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
334
import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter # from itertools import permutations,combinations def data():...
import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter # from itertools import permutations,combinations def data():...
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
370
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 10; const ll mod = 1e9 + 7; int f[N]; int g[N]; int F(int x) { return x == f[x] ? x : f[x] = F(f[x]); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i)...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 10; const ll mod = 1e9 + 7; int f[N]; int g[N]; int F(int x) { return x == f[x] ? x : f[x] = F(f[x]); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++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], ["-", 0, 11, 12, 2, 3, 4, 0, 69, 28, 22], ["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
228
#include <bits/stdc++.h> int main() { using namespace std; unsigned long N, M; cin >> N >> M; vector<unsigned long> uf(N), sz(N, 1); iota(begin(uf), end(uf), 0UL); const auto &find = [&uf](auto i) -> unsigned long { while (uf[i] != i) i = uf[i] = uf[uf[i]]; return i; }; const auto &unite ...
#include <bits/stdc++.h> int main() { using namespace std; unsigned long N, M; cin >> N >> M; vector<unsigned long> uf(N), sz(N, 1); iota(begin(uf), end(uf), 0UL); const auto &find = [&uf](auto i) -> unsigned long { while (uf[i] != i) i = uf[i] = uf[uf[i]]; return i; }; const auto &unite ...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
255
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define endl '\n' #define D(x) cerr << #x << " = " << (x) << '\n' #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef long long ll; const int N = 2e5 + 5; int n, m...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define endl '\n' #define D(x) cerr << #x << " = " << (x) << '\n' #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef long long ll; const int N = 2e5 + 5; int n, m...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
230
#include "bits/stdc++.h" #define hhh cerr << "hhh" << endl #define see(x) cerr << (#x) << '=' << (x) << endl using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pr; inline int read() { int x = 0, f = 1; char c = getchar(); while (c != '-' && c < 48) c = getchar(); if (c...
#include "bits/stdc++.h" #define hhh cerr << "hhh" << endl #define see(x) cerr << (#x) << '=' << (x) << endl using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pr; inline int read() { int x = 0, f = 1; char c = getchar(); while (c != '-' && c < 48) c = getchar(); if (c...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22]]
1
345
#include <bits/stdc++.h> #define ll long long #define vi vector<int> #define vll vector<long long> #define all(x) (x.begin(), x.end()) #define rep(i, a, b) for (int i = a; i < b; i++) #define F first #define S second #define endl "\n" #define FAST \ io...
#include <bits/stdc++.h> #define ll long long #define vi vector<int> #define vll vector<long long> #define all(x) (x.begin(), x.end()) #define rep(i, a, b) for (int i = a; i < b; i++) #define F first #define S second #define endl "\n" #define FAST \ io...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
314
#include <bits/stdc++.h> #define ll long long int #define M 1000000007 using namespace std; ll n, t, x, y, m, q; ll parent[200001] = {0}; ll find(ll x) { if (parent[x] == x) return x; return parent[x] = find(parent[x]); } void unian(ll x, ll y) { ll xset = find(parent[x]); ll yset = find(parent[y]); if (y...
#include <bits/stdc++.h> #define ll long long int #define M 1000000007 using namespace std; ll n, t, x, y, m, q; ll parent[200001] = {0}; ll find(ll x) { if (parent[x] == x) return x; return parent[x] = find(parent[x]); } void unian(ll x, ll y) { ll xset = find(parent[x]); ll yset = find(parent[y]); if (y...
[["+", 0, 11, 12, 2, 3, 4, 0, 69, 28, 22], ["+", 12, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["+", 12, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
249
/* * ---------------------------------------------------------------------------- * (: Bismillahir Rahmanir Rahim :) * File: /home/grim/Programming/Atcoder/Today/D_Friends.cpp * Project: /home/grim/Programming/Atcoder/Today * Created Date: Saturday, August 29th 2020, 6:37:06 pm * Author: Grim Firefly :) * Autho...
/* * ---------------------------------------------------------------------------- * (: Bismillahir Rahmanir Rahim :) * File: /home/grim/Programming/Atcoder/Today/D_Friends.cpp * Project: /home/grim/Programming/Atcoder/Today * Created Date: Saturday, August 29th 2020, 6:37:06 pm * Author: Grim Firefly :) * Autho...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
257
#include <bits/stdc++.h> using namespace std; int Parent[200005], Rank[200005]; map<int, int> mp; void MakeSet(int n) { Parent[n] = n; Rank[n] = 1; } int Find(int x) { if (Parent[x] != x) { Parent[x] = Find(Parent[x]); } return Parent[x]; } int Union(int xset, int yset) { if (xset == yset) return ...
#include <bits/stdc++.h> using namespace std; int Parent[200005], Rank[200005]; map<int, int> mp; void MakeSet(int n) { Parent[n] = n; Rank[n] = 1; } int Find(int x) { if (Parent[x] != x) { Parent[x] = Find(Parent[x]); } return Parent[x]; } int Union(int xset, int yset) { if (xset == yset) return ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
357
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; const int M...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; const int M...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
376
#include <bits/stdc++.h> using namespace std; using ll = long long; const int inf = 1e9 + 7; const ll longinf = 5LL << 60; const ll mod = 1e9 + 7; using Graph = vector<vector<int>>; int n, m; // 深さ優先探索 vector<bool> seen; // 探索したか記録 int main() { cin >> n >> m; Graph G(n); for (int i = 0; i < m; i++) { int ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int inf = 1e9 + 7; const ll longinf = 5LL << 60; const ll mod = 1e9 + 7; using Graph = vector<vector<int>>; int n, m; // 深さ優先探索 vector<bool> seen; // 探索したか記録 int main() { cin >> n >> m; Graph G(n); for (int i = 0; i < m; i++) { int ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
277
N,M = map(int,input().split()) color = [] colorStorage = [] for i in range(N): color.append(i) colorCount.append([i]) for _ in range(M): p,q = map(int,input().split()) p -= 1 q -= 1 if color[p] == color[q]: continue else: x = color[p] y = color[q] if len(col...
N,M = map(int,input().split()) color = [] colorStorage = [] for i in range(N): color.append(i) colorStorage.append([i]) for _ in range(M): p,q = map(int,input().split()) p -= 1 q -= 1 if color[p] == color[q]: continue else: x = color[p] y = color[q] if len(c...
[["-", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["-", 75, 76, 8, 196, 0, 7, 12, 206, 206, 22], ["+", 75, 76, 8, 196, 0, 7, 12, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]...
5
204
class union_find: def __init__(self, N): # 子なら親のインデックス、親ならunionのサイズを負数で格納 self.par = [-1 for i in range(N)] def root(self, i): if self.par[i] < 0: return i else: # 経路圧縮 self.par[i] = self.root(self.par[i]) return self.par[i] ...
class union_find: def __init__(self, N): # 子なら親のインデックス、親ならunionのサイズを負数で格納 self.par = [-1 for i in range(N)] def root(self, i): if self.par[i] < 0: return i else: # 経路圧縮 self.par[i] = self.root(self.par[i]) return self.par[i] ...
[["+", 0, 662, 31, 206, 206, 652, 63, 319, 500, 22], ["+", 0, 662, 31, 206, 206, 652, 63, 319, 0, 131], ["+", 0, 662, 31, 206, 206, 652, 63, 319, 319, 22], ["+", 0, 662, 31, 206, 206, 652, 3, 4, 0, 24], ["+", 0, 662, 31, 206, 206, 652, 3, 4, 0, 25]]
5
234
N,M=map(int,input().split()) F = [set() for _ in range(N)] for _ in range(M): a,b = map(lambda x: int(x)-1, input().split()) F[a].add(b) F[b].add(a) from collections import deque def bfs(): ans = 0 done = set() for i in range(N): if i in done: continue queue = deque([i]) num = 0 while que...
N,M=map(int,input().split()) F = [set() for _ in range(N)] for _ in range(M): a,b = map(lambda x: int(x)-1, input().split()) F[a].add(b) F[b].add(a) from collections import deque def bfs(): ans = 1 done = set() for i in range(N): if i in done: continue queue = deque([i]) num = 0 while que...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612]]
5
177
import collections import itertools import operator class UnionFind: def __init__(self, elems=None): class KeyDict(dict): def __missing__(self, key): self[key] = key return key self.parent = KeyDict() self.rank = collections.defaultdict(int) ...
import collections import itertools import operator class UnionFind: def __init__(self, elems=None): class KeyDict(dict): def __missing__(self, key): self[key] = key return key self.parent = KeyDict() self.rank = collections.defaultdict(int) ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
396
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <string> #define MAXN 200001 int max(int a, int b) { return a > b ? a : b; } int n, m, fa[MAXN], size[MAXN]; int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } void Union(int x, int y) { int rootx = find(x), rooty...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <string> #define MAXN 200001 int max(int a, int b) { return a > b ? a : b; } int n, m, fa[MAXN], size[MAXN]; int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } void Union(int x, int y) { int rootx = find(x), rooty...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
306
import java.io.*; import java.util.*; public class Main { static HashMap<Integer, Integer> h; static int v = 0; public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); ...
import java.io.*; import java.util.*; public class Main { static HashMap<Integer, Integer> h; static int v = 0; public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); ...
[["-", 0, 195, 8, 196, 0, 503, 49, 200, 51, 499], ["+", 0, 195, 8, 196, 0, 503, 49, 200, 51, 499]]
3
560
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): """ 親が同じか判別する """ if self.parents[x] < 0: retu...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): """ 親が同じか判別する """ if self.parents[x] < 0: retu...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612]]
5
399
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 //#define MOD 998244353 #define INF 1000000010 #define EPS 1e-9 #define F first #define S second #define debug(x) cout << x << endl; #define repi(i, x, n) for (int i = x; i < n; i++) #define rep(i, n) repi(i, 0, n) #define lp(i, n) repi(i, 0, n) #def...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 //#define MOD 998244353 #define INF 1000000010 #define EPS 1e-9 #define F first #define S second #define debug(x) cout << x << endl; #define repi(i, x, n) for (int i = x; i < n; i++) #define rep(i, n) repi(i, 0, n) #define lp(i, n) repi(i, 0, n) #def...
[["-", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13]]
1
356
#include <bits/stdc++.h> #ifdef DEBUG #define LOG(var, sep) (cerr << #var << " = " << (var) << (sep)) #define LOGM(msg) (cerr << (msg)) #define LOGV(vec, sep) \ { \ cerr << #vec <<...
#include <bits/stdc++.h> #ifdef DEBUG #define LOG(var, sep) (cerr << #var << " = " << (var) << (sep)) #define LOGM(msg) (cerr << (msg)) #define LOGV(vec, sep) \ { \ cerr << #vec <<...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
425
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) class UnionFind { public: vector<int> uni; UnionFind(int s) : uni(s, -1) {} //頂点aが所属するグループを調べる int root(int a) { if (uni[a] < 0) return a; return uni[a] = root(uni[a]); } //頂点...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) class UnionFind { public: vector<int> uni; UnionFind(int s) : uni(s, -1) {} //頂点aが所属するグループを調べる int root(int a) { if (uni[a] < 0) return a; return uni[a] = root(uni[a]); } //頂点...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
314
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1000000007; ll n, m; P p[200005]; ll c[200005]; ll ans; int par[100005], Rank[100005]; void init(ll n) { for (ll i = 0; i < n; i++) { par[i] = i; Rank[i] = 0; } } int find(ll x) { if (par[x] == x) { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1000000007; ll n, m; P p[200005]; ll c[200005]; ll ans; int par[200005], Rank[200005]; void init(ll n) { for (ll i = 0; i < n; i++) { par[i] = i; Rank[i] = 0; } } int find(ll x) { if (par[x] == x) { ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
364
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) struct UnionFind { vector<int> Parent; vector<int> Size; UnionFind(int N) : Parent(N), Size(N, 1) { for (int i = 0; i < N; i++) Parent[i] = i; } int root(int A) { if (Parent[A] == A) retur...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) struct UnionFind { vector<int> Parent; vector<int> Size; UnionFind(int N) : Parent(N), Size(N, 1) { for (int i = 0; i < N; i++) Parent[i] = i; } int root(int A) { if (Parent[A] == A) retur...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
350
#include <cstdio> using namespace std; const int maxn = 200010; int fa[maxn], siz[maxn], ans = 0; inline int getf(int x) { return x == fa[x] ? x : fa[x] = getf(fa[x]); } inline int Max(int a, int b) { return a > b ? a : b; } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) fa[i] ...
#include <cstdio> using namespace std; const int maxn = 200010; int fa[maxn], siz[maxn], ans = 0; inline int getf(int x) { return x == fa[x] ? x : fa[x] = getf(fa[x]); } inline int Max(int a, int b) { return a > b ? a : b; } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) fa[i] ...
[["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
231
#pragma once #undef _GLIBCXX_DEBUG #include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" #include "ext/rope" using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; void trace(int x) { cerr << x; } void trace(long x) { cerr << x; } void trace(long ...
#pragma once #undef _GLIBCXX_DEBUG #include "bits/stdc++.h" #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" #include "ext/rope" using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; void trace(int x) { cerr << x; } void trace(long x) { cerr << x; } void trace(long ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
1,388
// 私に忍び寄るのをやめてください、ありがとう #include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ll long long #define int long long #define mod 100...
// 私に忍び寄るのをやめてください、ありがとう #include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ll long long #define int long long #define mod 100...
[["-", 0, 11, 31, 69, 28, 2, 3, 4, 0, 22], ["+", 0, 11, 31, 69, 28, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
860
#include <bits/stdc++.h> #pragma GCC optimize("O2") using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define F first #define S second #define migmig \ ios::sync_with_stdio(fals...
#include <bits/stdc++.h> #pragma GCC optimize("O2") using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define F first #define S second #define migmig \ ios::sync_with_stdio(fals...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
1
331
#include <bits/stdc++.h> using namespace std; #define REP(i, a, b) for (int i = (a); i <= (b); i++) #define PER(i, a, b) for (int i = (a); i >= (b); i--) #define rep(i, a, b) for (int i = (a); i < (b); i++) #define all(S) (S).begin(), (S).end() #define pb push_back #define mk make_pair #define S second #define F first...
#include <bits/stdc++.h> using namespace std; #define REP(i, a, b) for (int i = (a); i <= (b); i++) #define PER(i, a, b) for (int i = (a); i >= (b); i--) #define rep(i, a, b) for (int i = (a); i < (b); i++) #define all(S) (S).begin(), (S).end() #define pb push_back #define mk make_pair #define S second #define F first...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
294
import sys def input(): return sys.stdin.readline()[:-1] 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]=r return r def m...
import sys def input(): return sys.stdin.readline()[:-1] 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]=r return r def m...
[["-", 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
461
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set>...
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set>...
[["+", 0, 7, 8, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 8, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 8, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 8, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
310
#include <bits/stdc++.h> using namespace std; using ll = long long; int Par[200010], Size[200010]; void init() { for (int i = 0; i < 200010; i++) { Par[i] = i; Size[i] = 1; } } int find(int x) { if (Par[x] == x) return x; return Par[x] = find(Par[x]); } void unite(int x, int y) { x = find(x); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int Par[200010], Size[200010]; void init() { for (int i = 0; i < 200010; i++) { Par[i] = i; Size[i] = 1; } } int find(int x) { if (Par[x] == x) return x; return Par[x] = find(Par[x]); } void unite(int x, int y) { x = find(x); ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
224
n = $stdin.readline.to_i a = $stdin.readline.chomp.split.map(&:to_i) m = 10 ** 6 d = Array.new(m + 1) 2.step(m) do |i| next if !d[i].nil? d[i] = i (m / i).times do |j| k = (j + 1) * i next if !d[k].nil? d[k] = i end end g = a[0] pc = true h = Hash.new(true) n.times do |i| g = g.gcd(a[i]) x ...
n = $stdin.readline.to_i a = $stdin.readline.chomp.split.map(&:to_i) m = 10 ** 6 d = Array.new(m + 1) 2.step(m) do |i| next if !d[i].nil? d[i] = i (m / i).times do |j| k = (j + 1) * i next if !d[k].nil? d[k] = i end end g = a[0] pc = true h = Hash.new(false) n.times do |i| g = g.gcd(a[i]) x...
[["-", 0, 493, 0, 662, 12, 652, 3, 4, 0, 146], ["+", 0, 493, 0, 662, 12, 652, 3, 4, 0, 147], ["-", 0, 89, 8, 170, 0, 121, 15, 738, 17, 47], ["-", 0, 89, 8, 170, 0, 121, 15, 738, 12, 612]]
4
215
// #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const int NINF = -1 * INF; const long long LLINF = 1ll << 60; const long long LLNINF = -1 * LLINF; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr> &operator<<(basic...
// #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const int NINF = -1 * INF; const long long LLINF = 1ll << 60; const long long LLNINF = -1 * LLINF; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr> &operator<<(basic...
[["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 72], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 21], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
797
from math import gcd n = int(input()) A = list(map(int, input().split())) f1 = True f2 = True c = [0] * (10**6+5) for a in A: c[a] = 1 for i in range(2, 10**6+5): cnt = 0 for j in range(i, 10**6+5, i): cnt += c[j] if cnt > 1: f1 = False g = 0 for i in range(len(A)): g = gcd(g, A[i]) if g != 1: f...
from math import gcd n = int(input()) A = list(map(int, input().split())) f1 = True f2 = True c = [0] * (10**6+5) for a in A: c[a] += 1 for i in range(2, 10**6+5): cnt = 0 for j in range(i, 10**6+5, i): cnt += c[j] if cnt > 1: f1 = False g = 0 for i in range(len(A)): g = gcd(g, A[i]) if g != 1: ...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]]
5
165
#include <bits/stdc++.h> using namespace std; #define fo(i, a, n) for (i = a; i < n; i++) #define ll long long #define deb(x) cout << #x << "=" << x << endl #define pb push_back #define mp make_pair #define ff first #define ss second #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sorta...
#include <bits/stdc++.h> using namespace std; #define fo(i, a, n) for (i = a; i < n; i++) #define ll long long #define deb(x) cout << #x << "=" << x << endl #define pb push_back #define mp make_pair #define ff first #define ss second #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sorta...
[["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
1
417
_n = gets.to_i a = gets.split.map(&:to_i) max = a.max sieve = Array.new(max + 1) { |i| i } prime_division = Array.new(max + 1) 2.upto(Math.sqrt(max).to_i) do |i| (max / i).times do |j| sieve[i * (j + 1)] = i if i < sieve[i * (j + 1)] end end 2.upto(max) do |i| h = Hash.new(0) j = i while j != 1 h[s...
_n = gets.to_i a = gets.split.map(&:to_i) max = a.max sieve = Array.new(max + 1) { |i| i } prime_division = Array.new(max + 1) 2.upto(Math.sqrt(max).to_i) do |i| (max / i).times do |j| sieve[i * (j + 1)] = i if i < sieve[i * (j + 1)] end end 2.upto(max) do |i| h = Hash.new(0) j = i while j != 1 h[s...
[["+", 196, 737, 8, 736, 0, 751, 8, 746, 0, 746], ["+", 0, 652, 196, 737, 8, 736, 0, 751, 0, 121], ["+", 196, 737, 8, 736, 0, 751, 15, 738, 31, 22], ["+", 196, 737, 8, 736, 0, 751, 15, 738, 17, 60], ["+", 196, 737, 8, 736, 0, 751, 15, 738, 12, 612]]
4
204
#pragma warning(disable : 4996) #include <algorithm> #include <stdio.h> using namespace std; int d[1001000]; int vis[1001000]; int gcd(int a, int b) { if (!a || !b) return a + b; else return a > b ? gcd(a % b, b) : gcd(a, b % a); } int a[1001000]; int main() { int n; scanf("%d", &n); for (int i = 1; i...
#pragma warning(disable : 4996) #include <algorithm> #include <stdio.h> using namespace std; int d[1001000]; int vis[1001000]; int gcd(int a, int b) { if (!a || !b) return a + b; else return a > b ? gcd(a % b, b) : gcd(a, b % a); } int a[1001000]; int main() { int n; scanf("%d", &n); for (int i = 1; i...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
377
#ifndef AUTO_UTIL_HEADER_HPP #define AUTO_UTIL_HEADER_HPP #include <bits/stdc++.h> #include <cassert> using std::cin, std::cout, std::bitset, std::complex; using std::min_element, std::max_element, std::accumulate; using std::priority_queue, std::set, std::map, std::unordered_map; using std::sort, std::greater, std::...
#ifndef AUTO_UTIL_HEADER_HPP #define AUTO_UTIL_HEADER_HPP #include <bits/stdc++.h> #include <cassert> using std::cin, std::cout, std::bitset, std::complex; using std::min_element, std::max_element, std::accumulate; using std::priority_queue, std::set, std::map, std::unordered_map; using std::sort, std::greater, std::...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
1,597
import math N = int(input()) a = list(map(int,input().split())) m = max(a) c = [0] * (m+1) for i in a: c[i] += 1 pairwise = True for i in range(2, m, 1): cnt = 0 for j in range(i, m, i): cnt += c[j] if cnt > 1: pairwise = False break if pairwise: print("pairwise coprime") exit() g = 0 ...
import math N = int(input()) a = list(map(int,input().split())) m = max(a) c = [0] * (m+1) for i in a: c[i] += 1 pairwise = True for i in range(2, m+1, 1): cnt = 0 for j in range(i, m+1, i): cnt += c[j] if cnt > 1: pairwise = False break if pairwise: print("pairwise coprime") exit() g ...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
156
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> using namespace std; #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_b...
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> using namespace std; #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_b...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
579
#include <algorithm> #include <array> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include ...
#include <algorithm> #include <array> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
2,562
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair<int, int>; using mp = map<string, int>; const int MOD = 1e9 + 7; const int INF = 1001001001; vector<int> factor(int n) { vector<int> res; for (int i = 2; i * i <= n; ++i) { while (n % i...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair<int, int>; using mp = map<string, int>; const int MOD = 1e9 + 7; const int INF = 1001001001; vector<int> factor(int n) { vector<int> res; for (int i = 2; i * i <= n; ++i) { while (n % i...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
334
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; using vvll = vector<vector<ll>>; using vll = vector<ll>; const ll MOD = 9998903; ll GCD(ll a, ll b) { if (b == 0) return a; else return GCD(b, a % b); } void solve() { ll i, j, count; ll N; cin >> N; vec...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; using vvll = vector<vector<ll>>; using vll = vector<ll>; const ll MOD = 9998903; ll GCD(ll a, ll b) { if (b == 0) return a; else return GCD(b, a % b); } void solve() { ll i, j, count; ll N; cin >> N; vec...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
276
#include <bits/stdc++.h> using namespace std; bool isPairwise = true; unordered_map<long long int, long long int> m; void factors(int a) { if (isPairwise == false) { return; } else { if (m[a]) { isPairwise = false; return; } else { m[a] = 1; } for (int i = 2; i * i < a; i++) ...
#include <bits/stdc++.h> using namespace std; bool isPairwise = true; unordered_map<long long int, long long int> m; void factors(int a) { if (isPairwise == false) { return; } else { if (m[a] && a != 1) { isPairwise = false; return; } else { m[a] = 1; } for (int i = 2; i * i ...
[["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
347
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; const int A = 1000005; int main() { int n; cin >> n; vector<int> a(n); vector<int> b(A); rep(i, n) { cin >> a[i]; ++b[a[i]]; } bool ispw = true; // pairwise coprimeの判定 for (int...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; const int A = 1000005; int main() { int n; cin >> n; vector<int> a(n); vector<int> b(A); rep(i, n) { cin >> a[i]; ++b[a[i]]; } bool ispw = true; // pairwise coprimeの判定 for (int...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
217
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); int G = 0; for (auto a : A) G = gcd(G, a); if (G > 2) return cout << "not coprime" ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); int G = 0; for (auto a : A) G = gcd(G, a); if (G > 1) return cout << "not coprime" ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
267
from math import gcd n = int(input()) a = list(map(int, input().split())) # 解説AC(a*loga) ans = 0 cnt = [0] * (max(a) + 1) for ai in a: ans = gcd(ans, ai) cnt[ai] += 1 if ans != 1: print('not coprime') elif any(sum(cnt[i::i]) > 1 for i in range(max(a) + 1)): print('setwise coprime') else: print('p...
from math import gcd n = int(input()) a = list(map(int, input().split())) # 解説AC(a*loga) ans = 0 cnt = [0] * (max(a) + 1) for ai in a: ans = gcd(ans, ai) cnt[ai] += 1 if ans != 1: print('not coprime') elif any(sum(cnt[i::i]) > 1 for i in range(2, max(a) + 1)): print('setwise coprime') else: print...
[["+", 3, 668, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 3, 668, 0, 659, 12, 652, 3, 4, 0, 21]]
5
120
from math import gcd def eratosthenes(n): prime = [] data = [i for i in range(n - 1)] while True: p = data[0] if n <= p ** 2: return prime + data prime.append(p) data = [e for e in data if e % p != 0] return data def factorize(N): # 素因数分解 prime = set(...
from math import gcd def eratosthenes(n): prime = [] data = [i for i in range(2, n + 1)] while True: p = data[0] if n <= p ** 2: return prime + data prime.append(p) data = [e for e in data if e % p != 0] return data def factorize(N): # 素因数分解 prime = s...
[["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 21], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72]]
5
232
from math import gcd def eratosthenes(n): prime = [] data = [i + 1 for i in range(1, n)] while True: p = data[0] if n <= p ** 2: return prime + data prime.append(p) data = [e for e in data if e % p != 0] return data def factorize(N): # 素因数分解 for p in ...
from math import gcd def eratosthenes(n): prime = [] data = [i + 1 for i in range(1, n)] while True: p = data[0] if n <= p ** 2: return prime + data prime.append(p) data = [e for e in data if e % p != 0] return data def factorize(N): # 素因数分解 for p in ...
[["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22]]
5
241
from sys import stdin,stdout def INPUT():return list(int(i) for i in stdin.readline().split()) def inp():return stdin.readline() def out(x):return stdout.write(x) import math import random J=int(1e9)+7 ###############################################################################\n=17 X=[False]*(10**6+1) P=[] for i i...
from sys import stdin,stdout def INPUT():return list(int(i) for i in stdin.readline().split()) def inp():return stdin.readline() def out(x):return stdout.write(x) import math import random J=int(1e9)+7 ###############################################################################\n=17 X=[False]*(10**6+1) P=[] for i i...
[["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
333
#include <bits/stdc++.h> using namespace std; #define ld double #define ll long long #define pb emplace_back #define mk make_pair #define mod 1000000007 #define ff first #define ss second #define sz(x) (int)x.size() #define FIO \ ios_base::sync_with_s...
#include <bits/stdc++.h> using namespace std; #define ld double #define ll long long #define pb emplace_back #define mk make_pair #define mod 1000000007 #define ff first #define ss second #define sz(x) (int)x.size() #define FIO \ ios_base::sync_with_s...
[["-", 0, 57, 15, 339, 51, 69, 341, 342, 0, 22], ["+", 0, 57, 15, 339, 51, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 27, 28, 69, 341, 342, 0, 22]]
1
411
#include <bits/stdc++.h> /*#ifndef LOCAL_RUN #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("avx2,tune=native") #endif*/ #define X first #define Y second using namespace std; typedef long long ll; typedef pair<int, int> pii; cons...
#include <bits/stdc++.h> /*#ifndef LOCAL_RUN #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("avx2,tune=native") #endif*/ #define X first #define Y second using namespace std; typedef long long ll; typedef pair<int, int> pii; cons...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
304
require "prime" #input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def ...
require "prime" #input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def ...
[["-", 0, 89, 8, 170, 0, 745, 8, 755, 12, 612], ["+", 8, 170, 0, 745, 8, 755, 12, 742, 500, 22], ["+", 8, 170, 0, 745, 8, 755, 12, 742, 0, 70], ["+", 8, 170, 0, 745, 8, 755, 12, 742, 0, 22], ["+", 8, 170, 0, 745, 8, 755, 12, 742, 0, 73]]
4
332
#include <iostream> using namespace std; const int lim = 1e6 + 2; int a[lim], lp[lim], pr[lim], avail[lim]; int n, cnt = 0; int _gcd(int a, int b) { if (b == 0) return a; return _gcd(b, a % b); } void sieve() { for (int i = 2; i <= lim; i++) { if (lp[i] == 0) lp[i] = pr[++cnt] = i; int j = 1; ...
#include <iostream> using namespace std; const int lim = 1e6 + 2; int a[lim], lp[lim], pr[lim], avail[lim]; int n, cnt = 0; int _gcd(int a, int b) { if (b == 0) return a; return _gcd(b, a % b); } void sieve() { for (int i = 2; i <= lim; i++) { if (lp[i] == 0) lp[i] = pr[++cnt] = i; int j = 1; ...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
406
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long int ll; const ll INF = 10000000000...
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long int ll; const ll INF = 10000000000...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 16, ...
1
356
from math import gcd n=int(input()) l=list(map(int,input().split())) mal=max(l) e=[i for i in range(mal+1)] x=2 while x*x <= mal: if x == e[x]: for m in range(x, len(e), n): if e[m] == m: e[m] = x x+=1 #print(e) s=set() f=1 for i in l: st = set() while i > 1: st....
from math import gcd n=int(input()) l=list(map(int,input().split())) mal=max(l) e=[i for i in range(mal+1)] x=2 while x*x <= mal: if x == e[x]: for m in range(x, len(e), x): if e[m] == m: e[m] = x x+=1 #print(e) s=set() f=0 for i in l: st = set() while i > 1: st....
[["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
214
N = int(input()) A = [0]*(1000001) for a in list(map(int, input().split())): A[a] += 1 # MFPF = Most Frequent Prime Factor MFPF_n = 0 seen_prime_factor = [0]*(1000001) for i in range(2, 1000001): if seen_prime_factor: continue n = i tmp = 0 while n < 1000001: tmp += A[n] see...
N = int(input()) A = [0]*(1000001) for a in list(map(int, input().split())): A[a] += 1 # MFPF = Most Frequent Prime Factor MFPF_n = 0 seen_prime_factor = [0]*(1000001) for i in range(2, 1000001): if seen_prime_factor[i]: continue n = i tmp = 0 while n < 1000001: tmp += A[n] ...
[["+", 0, 7, 8, 196, 0, 57, 15, 206, 0, 70], ["+", 0, 7, 8, 196, 0, 57, 15, 206, 206, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 206, 0, 73], ["+", 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]]
5
135
from math import gcd n = int(input()) a = list(map(int, input().split())) checker = [0 for _i in range(10**6+1)] for i in a: checker[i] += 1 if any(sum(checker[i::i])>1 for i in range(2, 10**6+1)): print('pairwise coprime') else: r = a[0] for i in a: r = gcd(r, i) if r == 1: print...
from math import gcd n = int(input()) a = list(map(int, input().split())) checker = [0 for _i in range(10**6+1)] for i in a: checker[i] += 1 if all(sum(checker[i::i])<2 for i in range(2,10**6+1)): print('pairwise coprime') else: r = a[0] for i in a: r = gcd(r, i) if r == 1: print(...
[["-", 36, 36, 0, 656, 0, 57, 15, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 652, 63, 22], ["-", 0, 57, 15, 652, 3, 668, 8, 666, 667, 47], ["-", 0, 57, 15, 652, 3, 668, 8, 666, 0, 612], ["+", 0, 57, 15, 652, 3, 668, 8, 666, 667, 18], ["+", 0, 57, 15, 652, 3, 668, 8, 666, 0, 612]]
5
132
from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) from math import gcd n=int(input()) a=lnii() g=a[0] for i in range(n): g=gcd(g,a[i]) def factorization(n): p=2 fcr=set() while p*p<=n: while n%p==0: fcr.add(p) ...
from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) from math import gcd n=int(input()) a=lnii() g=a[0] for i in range(n): g=gcd(g,a[i]) def factorization(n): p=2 fcr=set() while p*p<=n: while n%p==0: fcr.add(p) ...
[["-", 0, 7, 8, 196, 0, 57, 15, 206, 206, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 206, 206, 22], ["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
248