problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<pair<int, int>> vpii; #define F first #define S second #define PU push #define PUF push_front #define PUB push_back #define PO pop #define POF pop_front #define POB pop_back #de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<pair<int, int>> vpii; #define F first #define S second #define PU push #define PUF push_front #define PUB push_back #define PO pop #define POF pop_front #define POB pop_back #de...
replace
45
46
45
46
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; // 定数 // 円周率 const double pi = 3.141592653589793238462643383279; // 天井 const int INF = 1000000000; // = 10^9 const ll LINF = 100000000000000000; // = 10^17 // ABC文字列 const string ABC = "ABCDEFG...
#include <bits/stdc++.h> #define ll long long using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; // 定数 // 円周率 const double pi = 3.141592653589793238462643383279; // 天井 const int INF = 1000000000; // = 10^9 const ll LINF = 100000000000000000; // = 10^17 // ABC文字列 const string ABC = "ABCDEFG...
replace
212
213
212
213
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #include <stdio.h> using namespace std; typedef long long ll; typedef vector<ll> vll; #define fr(n, x) for (ll n = 0; n < x; n++) #define pf(x) cout << x << '\n' const ll mx = 1e5 + 4; const ll mod = 1e9 + 7; #pragma GCC optimize("O3") vll graph[mx]; bool vis[mx] = {0}; ll res = 0; void dfs(l...
#include <bits/stdc++.h> #include <stdio.h> using namespace std; typedef long long ll; typedef vector<ll> vll; #define fr(n, x) for (ll n = 0; n < x; n++) #define pf(x) cout << x << '\n' const ll mx = 3e5 + 4; const ll mod = 1e9 + 7; #pragma GCC optimize("O3") vll graph[mx]; bool vis[mx] = {0}; ll res = 0; void dfs(l...
replace
7
8
7
8
0
p02573
C++
Runtime Error
//----AUTHOR:kkdrummer----/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // #include <boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef unordered_set<ll> usll; typedef un...
//----AUTHOR:kkdrummer----/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // #include <boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef unordered_set<ll> usll; typedef un...
replace
123
126
123
126
0
p02573
C++
Runtime Error
#include <cmath> #include <iostream> #include <vector> using namespace std; const int N = 1e5 + 5; typedef long long ll; int father[N]; int height[N]; int people[N]; int find(int x) { if (x != father[x]) father[x] = find(father[x]); return father[x]; } // 合并并返回合并后的祖先序号 void Union(int x, int y) { x = find(...
#include <cmath> #include <iostream> #include <vector> using namespace std; const int N = 2e5 + 5; typedef long long ll; int father[N]; int height[N]; int people[N]; int find(int x) { if (x != father[x]) father[x] = find(father[x]); return father[x]; } // 合并并返回合并后的祖先序号 void Union(int x, int y) { x = find(...
replace
4
5
4
5
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #include <iostream> using namespace std; #define int long long int #define pb push_back #define fi(n) for (int i = 0; i < n; i++) #define fi1(n) for (int i = 1; i < n; i++) #define fj(n) for (int j = 0; j < n; j++) #define clr(x) memset(x, 0, sizeof(x)) #define print(x) ...
#include <bits/stdc++.h> #include <iostream> using namespace std; #define int long long int #define pb push_back #define fi(n) for (int i = 0; i < n; i++) #define fi1(n) for (int i = 1; i < n; i++) #define fj(n) for (int j = 0; j < n; j++) #define clr(x) memset(x, 0, sizeof(x)) #define print(x) ...
replace
57
59
57
59
-11
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int #define ull unsigned long long int #define ld long double #define mod 1000000007 #define FT() \ int t; \ scanf("%d", &t); ...
#include <bits/stdc++.h> #define ll long long int #define ull unsigned long long int #define ld long double #define mod 1000000007 #define FT() \ int t; \ scanf("%d", &t); ...
replace
25
26
25
26
-11
p02573
C++
Runtime Error
/*created by tanishk gupta*/ #include <bits/stdc++.h> 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 repl(i, a, n) for (long long int i = a; i < n; i++) #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #defin...
/*created by tanishk gupta*/ #include <bits/stdc++.h> 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 repl(i, a, n) for (long long int i = a; i < n; i++) #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #defin...
replace
74
76
74
76
0
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> // For policy based data structure /*#include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> */ using namespace std; /*using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_da...
#include <bits/stdc++.h> // For policy based data structure /*#include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> */ using namespace std; /*using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_da...
replace
38
39
38
40
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> // #define M_PI 3.14159265358979323846 using namespace std; #define rep(i, a, b) for (int i = a; i < b; ++i) #define repb(i, a, b) for (int i = a; i >= b; --i) #define vi vector<int> #define vb vector<bool> #define vs vector<string> #define vl vector<long long int> #define vc vector<char> #...
#include <bits/stdc++.h> // #define M_PI 3.14159265358979323846 using namespace std; #define rep(i, a, b) for (int i = a; i < b; ++i) #define repb(i, a, b) for (int i = a; i >= b; --i) #define vi vector<int> #define vb vector<bool> #define vs vector<string> #define vl vector<long long int> #define vc vector<char> #...
replace
58
59
58
59
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int back(int tree[], int start) { int root; if (tree[start] == -1) return start; root = back(tree, tree[start]); tree[start] = root; return root; } int main() { int n, m; cin >> n >> m; int h1[n], h2[n]; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int back(int tree[], int start) { int root; if (tree[start] == -1) return start; root = back(tree, tree[start]); tree[start] = root; return root; } int main() { int n, m; cin >> n >> m; int h1[n], h2[n]; ...
insert
23
23
23
25
-11
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define V vector typedef long long ll; typedef unsigned long long ull; typedef V<int> vi; typedef V<ll> vll; typedef V<string> vs; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define f(i, a) for (int i = 0; i < a; i++) #define fll(i, a) for (ll i = 0; i < a; i+...
#include <bits/stdc++.h> using namespace std; #define V vector typedef long long ll; typedef unsigned long long ull; typedef V<int> vi; typedef V<ll> vll; typedef V<string> vs; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define f(i, a) for (int i = 0; i < a; i++) #define fll(i, a) for (ll i = 0; i < a; i+...
replace
94
95
94
95
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long int #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define M 1000000007 vector<ll> adj[20000]; ll vis[20000]; void dfs(l...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define M 1000000007 vector<ll> adj[200006]; ll vis[200006]; void dfs...
replace
7
9
7
9
-11
p02573
C++
Runtime Error
#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; ...
replace
39
40
39
40
0
p02573
C++
Runtime Error
/* []__________[][][][]____[][][][][]__{}__[][][][]____[][][][][]__[][][][] []__________[]______________[]__________[]__________[]__________[]____[] []__________[][][][]________[]__________[][][][]____[]__________[]____[] []__________[]______________[]________________[]____[]__[][][]__[]____[] []_______...
/* []__________[][][][]____[][][][][]__{}__[][][][]____[][][][][]__[][][][] []__________[]______________[]__________[]__________[]__________[]____[] []__________[][][][]________[]__________[][][][]____[]__________[]____[] []__________[]______________[]________________[]____[]__[][][]__[]____[] []_______...
replace
15
17
15
17
-11
p02573
C++
Runtime Error
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */ // codeforces #include <bits/stdc++.h> // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define FASTIO ios::sync_w...
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */ // codeforces #include <bits/stdc++.h> // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define FASTIO ios::sync_w...
replace
38
39
38
39
0
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define min3(a, b, c) min(a, min(b, c)) #define max3(a, b, c) max(a, max(b, c)) typedef long long ll; typedef unsigned long long ull; using namespace std; struct UnionFind { vector<int> r; UnionFind(int N) { r = vector<int>(N, -1); } int root(int x) { if (r[x] < 0) return x; ...
#include <bits/stdc++.h> #define min3(a, b, c) min(a, min(b, c)) #define max3(a, b, c) max(a, max(b, c)) typedef long long ll; typedef unsigned long long ull; using namespace std; struct UnionFind { vector<int> r; UnionFind(int N) { r = vector<int>(N, -1); } int root(int x) { if (r[x] < 0) return x; ...
replace
12
13
12
14
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long vector<int> adj[100001]; bool visited[100001]; int groupsize = 0; int maxsize = 0; void dfs(int s) { visited[s] = true; groupsize += 1; for (int i = 0; i < adj[s].size(); ++i) { if (visited[adj[s][i]] == false) ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long vector<int> adj[1000001]; bool visited[1000001]; int groupsize = 0; int maxsize = 0; void dfs(int s) { visited[s] = true; groupsize += 1; for (int i = 0; i < adj[s].size(); ++i) { if (visited[adj[s][i]] == false)...
replace
4
6
4
6
-11
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll INF = 100000000; #define rep1(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, k, n) for (ll i = k; i < (n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll INF = 100000000; #define rep1(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, k, n) for (ll i = k; i < (n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return ...
insert
58
58
58
59
-11
p02573
Python
Runtime Error
n, m = map(int, input().split()) grid = [set() for i in range(n)] for i in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 grid[u].add(v) grid[v].add(u) cnt = 0 best = 0 visited = set() def dfs(x): global cnt if x in visited: return cnt += 1 visited.add(x) for...
n, m = map(int, input().split()) grid = [set() for i in range(n)] for i in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 grid[u].add(v) grid[v].add(u) cnt = 0 best = 0 visited = set() import sys sys.setrecursionlimit(1000000) def dfs(x): global cnt if x in visited: re...
insert
12
12
12
16
0
p02573
Python
Runtime Error
N, M = list(map(int, input().split())) d = {i: [] for i in range(1, N + 1)} for _ in range(M): a, b = list(map(int, input().split())) d[a].append(b) d[b].append(a) visited = [False for _ in range(N + 1)] def visit(x): if visited[x]: return 0 visited[x] = True z = 1 for y in d[x]...
import sys sys.setrecursionlimit(10000000) N, M = list(map(int, input().split())) d = {i: [] for i in range(1, N + 1)} for _ in range(M): a, b = list(map(int, input().split())) d[a].append(b) d[b].append(a) visited = [False for _ in range(N + 1)] def visit(x): if visited[x]: return 0 v...
insert
0
0
0
4
0
p02573
Python
Runtime Error
from collections import Counter N, M = map(int, input().split()) groups = [0] * (N + 1) group_num_list = [[0]] group_num = 1 for _ in range(M): A, B = map(int, input().split()) if groups[A] != 0 and groups[B] != 0: if groups[A] != groups[B]: lower = min(groups[A], groups[B]) hig...
from collections import Counter N, M = map(int, input().split()) groups = [0] * (N + 1) group_num_list = [[0]] group_num = 1 for _ in range(M): A, B = map(int, input().split()) if groups[A] != 0 and groups[B] != 0: if groups[A] != groups[B]: lower = min(groups[A], groups[B]) hig...
replace
31
32
31
32
0
p02573
Python
Time Limit Exceeded
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 = se...
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 = se...
replace
55
56
55
56
TLE
p02573
Python
Runtime Error
N, M = map(int, input().split()) C = [set([]) for i in range(N)] def dfs(n, y): seen[n] = True y += 1 for c in C[n]: if seen[c]: continue else: y = dfs(c, y) return y for i in range(M): a, b = map(int, input().split()) C[a - 1].add(b - 1) C[b - 1]....
import sys sys.setrecursionlimit(1000000) N, M = map(int, input().split()) C = [set([]) for i in range(N)] def dfs(n, y): seen[n] = True y += 1 for c in C[n]: if seen[c]: continue else: y = dfs(c, y) return y for i in range(M): a, b = map(int, input().s...
insert
0
0
0
5
0
p02573
Python
Time Limit Exceeded
import sys sys.setrecursionlimit(10**9) n, m = map(int, input().split()) root = [-1] * n def r(x): if root[x] < 0: return x return r(root[x]) def unite(x, y): x = r(x) y = r(y) if x == y: return root[x] += root[y] root[y] = x def size(x): return -1 * root[r(x)] ...
import sys sys.setrecursionlimit(10**9) n, m = map(int, input().split()) root = [-1] * n def r(x): if root[x] < 0: return x else: root[x] = r(root[x]) return root[x] def unite(x, y): x = r(x) y = r(y) if x == y: return root[x] += root[y] root[y] = x d...
replace
12
14
12
15
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define speed \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #pragma GCC target("avx2") #pragma GCC...
#include <bits/stdc++.h> #define speed \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #pragma GCC target("avx2") #pragma GCC...
replace
12
13
12
13
0
p02573
C++
Runtime Error
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> #define PI 3.14159265359 typedef long long ll; const int MOD = 1e9 + 7; const ll LLINF = 7e18; using namespace std; ll par[100001]; ll ran[...
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> #define PI 3.14159265359 typedef long long ll; const int MOD = 1e9 + 7; const ll LLINF = 7e18; using namespace std; ll par[200001]; ll ran[...
replace
16
19
16
19
0
p02573
C++
Time Limit Exceeded
/* #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") */ #include <bits/stdc++.h> #define ALL(x) (x).begin(), (x).end() #define ll long long #define db double #define ull unsigned long long #define pii_ pair<int, int> #define mp_ make_pair #define pb push_back #define fi first #define se second #define re...
/* #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") */ #include <bits/stdc++.h> #define ALL(x) (x).begin(), (x).end() #define ll long long #define db double #define ull unsigned long long #define pii_ pair<int, int> #define mp_ make_pair #define pb push_back #define fi first #define se second #define re...
replace
29
30
29
32
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define mes(a, b) memset((a), (b), sizeof((a))) #define syio \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define mes(a, b) memset((a), (b), sizeof((a))) #define syio \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); ...
replace
32
33
32
33
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) using namespace std; const int MOD = 1000000007; struct UnionFind { // 自身が親であれば、その集合に属する頂点数に-1を掛けたもの // そうでなければ親のid vector<int> r; UnionFind(int N) { r = vector<int>(N, -1); } int root(int x) { if (r[x] < 0) ...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) using namespace std; const int MOD = 1000000007; struct UnionFind { // 自身が親であれば、その集合に属する頂点数に-1を掛けたもの // そうでなければ親のid vector<int> r; UnionFind(int N) { r = vector<int>(N, -1); } int root(int x) { if (r[x] < 0) ...
replace
40
41
40
41
0
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // syntax sugar: `for (int i = 0; i < N; ++i)` #define rep(i, N) for (int i = 0; i < (int)(N); ++i) #define rep2(i, startValue, N) \ for (int i = (int)(startValue); i < (int)(N); ++i) // syntax sugar: `for (int i = 0; i < ...
#include <bits/stdc++.h> using namespace std; // syntax sugar: `for (int i = 0; i < N; ++i)` #define rep(i, N) for (int i = 0; i < (int)(N); ++i) #define rep2(i, startValue, N) \ for (int i = (int)(startValue); i < (int)(N); ++i) // syntax sugar: `for (int i = 0; i < ...
replace
38
40
38
43
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef set<int> si;...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef set<int> si;...
replace
51
52
51
52
0
p02573
C++
Runtime Error
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Name:- OMHARI Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY) Email:- omharicu@gmail.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include <bits/stdc++.h> using namespace std; #define F first #define S s...
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Name:- OMHARI Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY) Email:- omharicu@gmail.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include <bits/stdc++.h> using namespace std; #define F first #define S s...
replace
33
35
33
35
-11
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long ll read() { ll x = 0, f = 1; char ch = ' '; while (!isdigit(ch)) { ch = getchar(); if (ch == '-') f = -1; } while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar(); return x * f; } int f[100005], n, m, maxn,...
#include <bits/stdc++.h> using namespace std; #define ll long long ll read() { ll x = 0, f = 1; char ch = ' '; while (!isdigit(ch)) { ch = getchar(); if (ch == '-') f = -1; } while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar(); return x * f; } int f[500005], n, m, maxn,...
replace
15
16
15
16
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int p[100005], n, m, g[100005], ans = 0, nc = 0; vector<int> v; int fa(int x) { return (p[x] == x) ? x : (p[x] = fa(p[x])); } void merge(int x, int y) { int fx = fa(x), fy = fa(y); p[fx] = fy; } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) p[...
#include <bits/stdc++.h> using namespace std; int p[200005], n, m, g[200005], ans = 0, nc = 0; vector<int> v; int fa(int x) { return (p[x] == x) ? x : (p[x] = fa(p[x])); } void merge(int x, int y) { int fx = fa(x), fy = fa(y); p[fx] = fy; } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) p[...
replace
2
3
2
3
0
p02573
Python
Time Limit Exceeded
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 = se...
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 = se...
replace
64
66
64
66
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define repb(i, n) for (ll i = (n)-1; i >= 0; i--) #define rep(i, n) repd(i, 0, n) using namespace std; using ll = long long; using ul = unsigned long long; using ld = long double; ll mod = 1000000007; class UnionFind { private: ll num;...
#include <bits/stdc++.h> #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define repb(i, n) for (ll i = (n)-1; i >= 0; i--) #define rep(i, n) repd(i, 0, n) using namespace std; using ll = long long; using ul = unsigned long long; using ld = long double; ll mod = 1000000007; class UnionFind { private: ll num;...
replace
25
26
25
26
0
p02573
C++
Runtime Error
#include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <time.h> #include <vector> #define h 200010 #define lli long long int #define pb push_back #define pof pop_front #define lb lower_bo...
#include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <time.h> #include <vector> #define h 200010 #define lli long long int #define pb push_back #define pof pop_front #define lb lower_bo...
replace
25
26
25
26
-11
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const long double pi = acos(-1); #define x first #define y second #define read(n, a) \ for (int i = 0; i < n; i++) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const long double pi = acos(-1); #define x first #define y second #define read(n, a) \ for (int i = 0; i < n; i++) ...
replace
17
18
17
18
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { ...
insert
57
57
57
58
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mod 1000000007 bool vis[100005]; vector<ll> gr[100005]; ll dfs(ll u) { vis[u] = true; ll ans = 1; for (auto v : gr[u]) { if (!vis[v]) { ans += dfs(v); } } return ans; } int main() { ll n, m; cin >> n >> m; memset...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mod 1000000007 bool vis[200005]; vector<ll> gr[200005]; ll dfs(ll u) { vis[u] = true; ll ans = 1; for (auto v : gr[u]) { if (!vis[v]) { ans += dfs(v); } } return ans; } int main() { ll n, m; cin >> n >> m; memset...
replace
4
6
4
6
0
p02573
C++
Runtime Error
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, -1, 0, 1}; const int LIT = 1e9 + 7; int n, m; vector<int> Map[20001]; set<pair<int, int>> s; void solve() { cin >> n >> m; for (in...
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, -1, 0, 1}; const int LIT = 1e9 + 7; int n, m; vector<int> Map[200001]; set<pair<int, int>> s; void solve() { cin >> n >> m; for (i...
replace
14
15
14
15
0
p02573
Python
Time Limit Exceeded
import sys import heapq sys.setrecursionlimit(10**8) input = sys.stdin.readline class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.paren...
import sys import heapq sys.setrecursionlimit(10**8) input = sys.stdin.readline class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.paren...
replace
53
54
53
54
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> p; UnionFind(int n) { p = vector<int>(n, -1); } int root(int c) { if (p.at(c) < 0) return c; else return root(p.at(c)); } void unite(int a, int b) { int ra = root(a); int rb = root(b); if (ra == rb...
#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> p; UnionFind(int n) { p = vector<int>(n, -1); } int root(int c) { if (p.at(c) < 0) return c; else return p.at(c) = root(p.at(c)); } void unite(int a, int b) { int ra = root(a); int rb = root(b); if...
replace
12
13
12
13
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pi acos(-1.0) #define pb push_back #define mp make_pair #define ll long long #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define testcase \ ll T; ...
#include <bits/stdc++.h> using namespace std; #define pi acos(-1.0) #define pb push_back #define mp make_pair #define ll long long #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define testcase \ ll T; ...
replace
51
53
51
58
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct bcj { int f[100001]; int size[100001]; int find(int n) { if (f[n] == n) return n; else f[n] = find(f[n]); return f[n]; } int add(int x, int y) { int a = find(x); int b = find(y); if (a == b) return 0; else { ...
#include <bits/stdc++.h> using namespace std; struct bcj { int f[200001]; int size[200001]; int find(int n) { if (f[n] == n) return n; else f[n] = find(f[n]); return f[n]; } int add(int x, int y) { int a = find(x); int b = find(y); if (a == b) return 0; else { ...
replace
3
5
3
5
0
p02573
C++
Time Limit Exceeded
#include <iostream> typedef std::pair<int, int> Edge; int find(int *par, int x) { if (x == par[x]) return x; else return find(par, par[x]); } void unite(int *par, int x, int y) { par[find(par, x)] = find(par, y); } bool isSame(int *par, int x, int y) { return find(par, x) == find(par, y); } int main() {...
#include <iostream> typedef std::pair<int, int> Edge; int find(int *par, int x) { if (x == par[x]) return x; else return par[x] = find(par, par[x]); } void unite(int *par, int x, int y) { par[find(par, x)] = find(par, y); } bool isSame(int *par, int x, int y) { return find(par, x) == find(par, y); } int...
replace
7
8
7
8
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second #define pl pair<long long, long long> #define pi pair<int, int> #define lb(v, x) lower_bound(v.begin(), v.end(), x) - v.begin() #define ub(v, x) upper_bound(v.begin(), v.end(), ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second #define pl pair<long long, long long> #define pi pair<int, int> #define lb(v, x) lower_bound(v.begin(), v.end(), x) - v.begin() #define ub(v, x) upper_bound(v.begin(), v.end(), ...
replace
18
19
18
19
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; int ans = 1; int par[200001] = {}; int r[200001] = {}; int si[200001] = {}; int find(int x) { if (par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x, int y) { x = find(x); y = find(y); if (x == y)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int ans = 1; int par[200001] = {}; int r[200001] = {}; int si[200001] = {}; int find(int x) { if (par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x, int y) { x = find(x); y = find(y); if (x == y)...
replace
22
23
22
23
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> typedef long long int ll; using namespace std; const int MX = 100010; vector<vector<int>> adj(MX + 1); // adding edge utility void add_edge(vector<vector<int>> &ref, int start, int end, bool dir) { ref[start].push_back(end); if (!dir) { ref[end].push_back(start); } } std::vector<...
#include <bits/stdc++.h> typedef long long int ll; using namespace std; const int MX = 400010; vector<vector<int>> adj(MX + 1); // adding edge utility void add_edge(vector<vector<int>> &ref, int start, int end, bool dir) { ref[start].push_back(end); if (!dir) { ref[end].push_back(start); } } std::vector<...
replace
5
6
5
6
-11
p02573
C++
Runtime Error
// C++ implementation of the above approach #include <bits/stdc++.h> #define int long long using namespace std; const int maxx = 100005; vector<int> graph[maxx]; // Function to perform the DFS calculating the // count of the elements in a connected component void dfs(int curr, int &cnt, int *visited, vector<int> &duri...
// C++ implementation of the above approach #include <bits/stdc++.h> #define int long long using namespace std; const int maxx = 200005; vector<int> graph[maxx]; // Function to perform the DFS calculating the // count of the elements in a connected component void dfs(int curr, int &cnt, int *visited, vector<int> &duri...
replace
4
5
4
5
0
p02573
C++
Runtime Error
// It doesn't matter as long as you rise to the top - Katsuki Bakugo #include <bits/stdc++.h> using namespace std; #define Fast_as_duck \ ios::sync_with_stdio(false); \ cin.tie(0); ...
// It doesn't matter as long as you rise to the top - Katsuki Bakugo #include <bits/stdc++.h> using namespace std; #define Fast_as_duck \ ios::sync_with_stdio(false); \ cin.tie(0); ...
replace
19
20
19
20
0
p02573
C++
Time Limit Exceeded
/* author:ujwalll */ #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define for1(i, n) for (int i = 1; i <= n; i++) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) const int INF = 1...
/* author:ujwalll */ #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define for1(i, n) for (int i = 1; i <= n; i++) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) const int INF = 1...
replace
37
38
37
38
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define F first #define S second #define endl '\n' #define all(x) (x).begin(), (x).end() #define FOR(i, n) for (int i = 0; i < n; i++) #define FORR(i, a, b) for (int i = a; i < b; i++) #define fast ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define F first #define S second #define endl '\n' #define all(x) (x).begin(), (x).end() #define FOR(i, n) for (int i = 0; i < n; i++) #define FORR(i, a, b) for (int i = a; i < b; i++) #define fast ...
replace
48
49
48
49
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int #define li long int #define ld long double #define pb push_back using namespace std; vector<int> lis[100001]; bool vis[100001]; void dfs(int node, int &curr) { vis[node] = true; curr++; for (int x : lis[node]) { if (!vis[x]) { dfs(x, curr); } } }...
#include <bits/stdc++.h> #define ll long long int #define li long int #define ld long double #define pb push_back using namespace std; vector<int> lis[200001]; bool vis[200001]; void dfs(int node, int &curr) { vis[node] = true; curr++; for (int x : lis[node]) { if (!vis[x]) { dfs(x, curr); } } }...
replace
7
9
7
9
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #include <iostream> using namespace std; #define ll long long int const int md = 1e9 + 7; ll Parent[100000]; ll sze[100000]; void Build(int n) { for (ll i = 1; i <= n; i++) { Parent[i] = i; sze[i] = 1; } } ll find(ll u) { if (Parent[u] == u) return u; else { return P...
#include <bits/stdc++.h> #include <iostream> using namespace std; #define ll long long int const int md = 1e9 + 7; ll Parent[200005]; ll sze[200005]; void Build(int n) { for (ll i = 1; i <= n; i++) { Parent[i] = i; sze[i] = 1; } } ll find(ll u) { if (Parent[u] == u) return u; else { return P...
replace
7
9
7
9
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll mod = 1e9 + 7; #define pival 3.14159265359 #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define pqq priority_queue #define all(a) a.beg...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll mod = 1e9 + 7; #define pival 3.14159265359 #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define pqq priority_queue #define all(a) a.beg...
replace
26
27
26
27
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int64 long long const int mod = (int)1e9 + 7; const int nax = 1e5 + 5; vector<int> par(nax), siz(nax); int find(int u) { if (par[u] == u) return u; return par[u] = find(par[u]); } void union_set(int a, int b) { a = find(a), b = find(b); if (a == b) ...
#include <bits/stdc++.h> using namespace std; #define int64 long long const int mod = (int)1e9 + 7; const int nax = 2e5 + 5; vector<int> par(nax), siz(nax); int find(int u) { if (par[u] == u) return u; return par[u] = find(par[u]); } void union_set(int a, int b) { a = find(a), b = find(b); if (a == b) ...
replace
7
8
7
8
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #define pb push_back #define mpr make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define ll long long #define ld long double #define all(arr) arr.begin(), arr.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define fo(i,...
#include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #define pb push_back #define mpr make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define ll long long #define ld long double #define all(arr) arr.begin(), arr.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define fo(i,...
replace
35
36
35
36
0
p02573
C++
Runtime Error
#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...
replace
36
37
36
37
-11
p02573
C++
Runtime Error
/* LANG:C++ PROB: */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> #include <iostream> // #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall...
/* LANG:C++ PROB: */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> #include <iostream> // #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall...
replace
57
58
57
58
-11
p02573
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> // #include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> // #include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7...
replace
35
36
35
36
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using i16 = std::int16_t; using i32 = std::int32_t; using i64 = std::int64_t; using usize = std::size_t; using namespace std; #define rep(i, max) for (usize i = 0; i < max; ++i) #define loop while (true) #define allOf(collection) collection.begin(), collection.end() unique_ptr<string> readLi...
#include <bits/stdc++.h> using i16 = std::int16_t; using i32 = std::int32_t; using i64 = std::int64_t; using usize = std::size_t; using namespace std; #define rep(i, max) for (usize i = 0; i < max; ++i) #define loop while (true) #define allOf(collection) collection.begin(), collection.end() unique_ptr<string> readLi...
insert
112
112
112
114
TLE
p02573
C++
Time Limit Exceeded
/*author @dhanush*/ #include <bits/stdc++.h> using namespace std; #define ll long long #define boost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define pb push_back #define se second #define fi firs...
/*author @dhanush*/ #include <bits/stdc++.h> using namespace std; #define ll long long #define boost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define pb push_back #define se second #define fi firs...
replace
16
20
16
23
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define M_PI 3.1415926535 #define ll long long #define ld long double #define all(a) a.begin(), a.end() #define Summon_Tourist \ ios::sync_with_stdio(false); \ cin.ti...
#include <bits/stdc++.h> using namespace std; #define M_PI 3.1415926535 #define ll long long #define ld long double #define all(a) a.begin(), a.end() #define Summon_Tourist \ ios::sync_with_stdio(false); \ cin.ti...
replace
19
21
19
21
0
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int findSet(vector<int> a, int i) { if (a[i] < 0) return i; return a[i] = findSet(a, a[i]); } void mergeSets(vector<int> &a, int i, int j) { int x = findSet(a, i); int y = findSet(a, j); if (x == y) { return; } if (a[x] > a[y]) { int t = x; x...
#include <bits/stdc++.h> using namespace std; int findSet(vector<int> &a, int i) { if (a[i] < 0) return i; return a[i] = findSet(a, a[i]); } void mergeSets(vector<int> &a, int i, int j) { int x = findSet(a, i); int y = findSet(a, j); if (x == y) { return; } if (a[x] > a[y]) { int t = x; ...
replace
3
4
3
4
TLE
p02573
C++
Time Limit Exceeded
#include <iostream> #include <map> #include <set> #include <stdio.h> #include <string.h> #include <vector> using namespace std; int dfs(int i, vector<bool> &visited, std::map<int, std::set<int>> friends) { int result = 1; for (std::set<int>::iterator it = friends[i].begin(); it != friends[i].end(); ++it) { ...
#include <iostream> #include <map> #include <set> #include <stdio.h> #include <string.h> #include <vector> using namespace std; int dfs(int i, vector<bool> &visited, std::map<int, std::set<int>> &friends) { int result = 1; for (std::set<int>::iterator it = friends[i].begin(); it != friends[i].end(); ++it) {...
replace
8
9
8
9
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <typename T> string join(vector<T> &vec, string &sp) { int si = vec.length; if (si == 0) { return ""; } else { stringstream ss; rep(i, si - 1) { ss << vec[i] << sp; } ss << vec[si - 1]; ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <typename T> string join(vector<T> &vec, string &sp) { int si = vec.length; if (si == 0) { return ""; } else { stringstream ss; rep(i, si - 1) { ss << vec[i] << sp; } ss << vec[si - 1]; ...
replace
18
20
18
22
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define fr(i, n) for (int i = 1; i <= n; i++) #define mod 1000000007 #define pb push_back #define ff first #define ss second #define ii pair<ll, ll> #define vi vector<int> #define vii vector<ii> #define ll long long int #define INF 1000000000 #define endl '\n' using namespace std; vector<int> v...
#include <bits/stdc++.h> #define fr(i, n) for (int i = 1; i <= n; i++) #define mod 1000000007 #define pb push_back #define ff first #define ss second #define ii pair<ll, ll> #define vi vector<int> #define vii vector<ii> #define ll long long int #define INF 1000000000 #define endl '\n' using namespace std; vector<int> v...
replace
13
16
13
16
0
p02573
C++
Time Limit Exceeded
#include <iostream> using namespace std; int a[200005]; int cnt[200005]; int findroot(int v) { return a[v] == v ? v : findroot(a[v]); } int main() { int n, m; cin >> n; cin >> m; for (int i = 1; i <= n; i++) { a[i] = i; cnt[i] = 1; } int max = 0; for (int i = 0; i < m; i++) { int x, y; cin...
#include <iostream> using namespace std; int a[200005]; int cnt[200005]; int findroot(int v) { return a[v] == v ? v : a[v] = findroot(a[v]); } int main() { int n, m; cin >> n; cin >> m; for (int i = 1; i <= n; i++) { a[i] = i; cnt[i] = 1; } int max = 0; for (int i = 0; i < m; i++) { int x, y; ...
replace
4
5
4
5
TLE
p02573
C++
Runtime Error
#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...
replace
43
44
43
44
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int mex = 100005; #define ll long long #define test \ int t; \ cin >> t; ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int mex = 200005; #define ll long long #define test \ int t; \ cin >> t; ...
replace
3
4
3
4
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define int long long #define F first #define S second #define all(x) (x).begin(), (x).end() using namespace std; vector<vector<int>> g(100005); int u[100005]; void dfs(int v, int &cnt) { u[v] = 1, cnt++; for (int to : g[v]) if (!u[to]) dfs(to, cnt); } int32_t main() { ios...
#include <bits/stdc++.h> #define int long long #define F first #define S second #define all(x) (x).begin(), (x).end() using namespace std; vector<vector<int>> g(200005); int u[200005]; void dfs(int v, int &cnt) { u[v] = 1, cnt++; for (int to : g[v]) if (!u[to]) dfs(to, cnt); } int32_t main() { ios...
replace
10
12
10
12
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mx = 200009; ll mod = 1000000007; ll a[mx]; /* int siz[mx]; int par[mx]; int parent(int i){ while(i!=par[i]){ i=par[i]; } return i; } void unit(int x,int y){ if(siz[x]<siz[y]){swap(x,y);} int ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mx = 200009; ll mod = 1000000007; ll a[mx]; /* int siz[mx]; int par[mx]; int parent(int i){ while(i!=par[i]){ i=par[i]; } return i; } void unit(int x,int y){ if(siz[x]<siz[y]){swap(x,y);} int ...
replace
34
35
34
35
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> using namespace std; const int mxn = 1e5 + 5; const int inf = 1e9; int sz[mxn]; int par[mxn]; int findrep(int u) { return par[u] == u ? u : (par[u] = findrep(par[u])); } void unite(int u, int v) { u = findrep(u); v = findrep(v); if (u =...
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> using namespace std; const int mxn = 2e5 + 5; const int inf = 1e9; int sz[mxn]; int par[mxn]; int findrep(int u) { return par[u] == u ? u : (par[u] = findrep(par[u])); } void unite(int u, int v) { u = findrep(u); v = findrep(v); if (u =...
replace
4
5
4
5
0
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace boost::multiprecision; typedef long long int ll; typedef long double ld; #define PI 3.141592653589793 #define MOD 1000000007 #define ALL(obj) (obj).begin(), (obj).end() template <class T> inline bool chmax(T ...
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace boost::multiprecision; typedef long long int ll; typedef long double ld; #define PI 3.141592653589793 #define MOD 1000000007 #define ALL(obj) (obj).begin(), (obj).end() template <class T> inline bool chmax(T ...
replace
83
93
83
84
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> adj_list[100005]; void dfs(int u, vector<int> &flag, int *kitna) { *kitna = *kitna + 1; flag[u] = 1; for (auto v : adj_list[u]) { if (flag[v] == -1) { dfs(v, flag, kitna); } } } int32_t main() { vector<int> arr; ...
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> adj_list[200005]; void dfs(int u, vector<int> &flag, int *kitna) { *kitna = *kitna + 1; flag[u] = 1; for (auto v : adj_list[u]) { if (flag[v] == -1) { dfs(v, flag, kitna); } } } int32_t main() { vector<int> arr; ...
replace
4
5
4
5
0
p02573
C++
Runtime Error
#include <algorithm> #include <cstring> #include <iostream> #include <vector> using namespace std; const int N = (int)1e5 + 7; int n, m; vector<int> g[N]; bool used[N]; int dfs(int v) { used[v] = 1; int q = 1; for (int i = 0; i < g[v].size(); ++i) { int to = g[v][i]; if (!used[to]) { q += dfs(to...
#include <algorithm> #include <cstring> #include <iostream> #include <vector> using namespace std; const int N = (int)2e5 + 7; int n, m; vector<int> g[N]; bool used[N]; int dfs(int v) { used[v] = 1; int q = 1; for (int i = 0; i < g[v].size(); ++i) { int to = g[v][i]; if (!used[to]) { q += dfs(to...
replace
7
8
7
8
0
p02573
C++
Runtime Error
/***** author : C0d1ngPhenomena *****/ #include <bits/stdc++.h> #define endl "\n" #define ll long long int #define TestCases \ int T; \ cin >> T; ...
/***** author : C0d1ngPhenomena *****/ #include <bits/stdc++.h> #define endl "\n" #define ll long long int #define TestCases \ int T; \ cin >> T; ...
replace
31
33
31
33
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define IO \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define IO \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
replace
15
16
15
16
0
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int a[200020]; int si[200020]; int ff(int x) { return a[x] == x ? x : ff(a[x]); } int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) a[i] = i, si[i] = 1; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; x = ff(x); y = f...
#include <bits/stdc++.h> using namespace std; int a[200020]; int si[200020]; int ff(int x) { return a[x] = a[x] == x ? x : ff(a[x]); } int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) a[i] = i, si[i] = 1; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; x = ff(x); ...
replace
7
8
7
8
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define F first #define S second #define MP make_pair #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define LCM(a, b) (a) / __gcd((a), (b)) * (b) #define CEIL(a, b) (a) / (b) + (((a) % (b)) ? 1 : 0) #define log_2(a) (log((a)) / log(2)) #define ln '...
#include <bits/stdc++.h> #define F first #define S second #define MP make_pair #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define LCM(a, b) (a) / __gcd((a), (b)) * (b) #define CEIL(a, b) (a) / (b) + (((a) % (b)) ? 1 : 0) #define log_2(a) (log((a)) / log(2)) #define ln '...
replace
66
67
66
67
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define LL long long int #define FASTIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ co...
#include <bits/stdc++.h> using namespace std; #define LL long long int #define FASTIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ co...
replace
9
11
9
10
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct UnionFind { vector<int> d; UnionFind(int n = 0) : d(n, -1) {} int find(int x) { if (d.at(x) < 0) { return x; } return d.at(x) = find(d.at(x)); } bool unite(int x, int y) { x = find(x); y = find(y); if (x ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct UnionFind { vector<int> d; UnionFind(int n = 0) : d(n, -1) {} int find(int x) { if (d.at(x) < 0) { return x; } return d.at(x) = find(d.at(x)); } bool unite(int x, int y) { x = find(x); y = find(y); if (x ...
insert
37
37
37
39
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 5) >= this->size() (which is 5)
p02573
C++
Runtime Error
#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) #de...
#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) #de...
replace
46
47
46
47
0
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int NMAX = 2e5 + 10; const int MOD = 1e9 + 7; int pre[NMAX], a[NMAX]; inline int find(int x) { return x == pre[x] ? x : find(pre[x]); } int main(int argc, char const *argv[]) { int n, m; scanf("%d%d", &n, &m); for (register int i = 1; i <...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int NMAX = 2e5 + 10; const int MOD = 1e9 + 7; int pre[NMAX], a[NMAX]; inline int find(int x) { return pre[x] = (x == pre[x] ? x : find(pre[x])); } int main(int argc, char const *argv[]) { int n, m; scanf("%d%d", &n, &m); for (register int...
replace
8
9
8
9
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> d(n); vector<int> list(n); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; d[a].push_back(b); d[b].push_back(a); } int ans = 0; for (int...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> d(n); vector<int> list(n); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; d[a].push_back(b); d[b].push_back(a); } int ans = 0; for (int...
insert
28
28
28
30
TLE
p02573
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define X first #define Y second #define nl '\n' #define AC return 0 #define pb(a) push_back(a) #define mst(a, b) memset(a, b, sizeof a) #define rep(i, n) for (int i = 0; (i) < (n); i++) #define rep1(i, n) for (int i = 1; (i) <= (n); ...
#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define X first #define Y second #define nl '\n' #define AC return 0 #define pb(a) push_back(a) #define mst(a, b) memset(a, b, sizeof a) #define rep(i, n) for (int i = 0; (i) < (n); i++) #define rep1(i, n) for (int i = 1; (i) <= (n); ...
replace
23
24
23
24
TLE
p02573
C++
Runtime Error
// control+option+n to run! #include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--) #define vll vector<long long> #define sll set<long long> #define ld long double #define inf 10000...
// control+option+n to run! #include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--) #define vll vector<long long> #define sll set<long long> #define ld long double #define inf 10000...
replace
20
22
20
22
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) struct UnionFind { vector<int> d; // データ UnionFind(int n = 0) : d(n, -1) {} // 初期値は全部根(-1)とする int find(int x) { if (d[x] < 0) return x; return d[x] = find(d[x]); } bool unite(in...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) struct UnionFind { vector<int> d; // データ UnionFind(int n = 0) : d(n, -1) {} // 初期値は全部根(-1)とする int find(int x) { if (d[x] < 0) return x; return d[x] = find(d[x]); } bool unite(in...
replace
29
31
29
31
0
p02573
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <vector> using namespace std; const int MAXN = 1e5 + 7; int N, M; vector<int> graph[MAXN]; bool visited[MAXN]; int DFS(int cur) { int ret = 1; visited[cur] = true; for (auto adj : graph[cur]) { if (visited[adj]) continue; ret += DFS(adj); } re...
#include <algorithm> #include <cstdio> #include <vector> using namespace std; const int MAXN = 2e5 + 7; int N, M; vector<int> graph[MAXN]; bool visited[MAXN]; int DFS(int cur) { int ret = 1; visited[cur] = true; for (auto adj : graph[cur]) { if (visited[adj]) continue; ret += DFS(adj); } re...
replace
6
7
6
7
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; vector<int> adj[MAXN]; bool visited[MAXN]; int n, m, mx = 0, curr = 0; void dfs(int node) { visited[node] = true; for (int next : adj[node]) { if (!visited[next]) { curr++; dfs(next); } } } int main() { cin >> n >> m; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000; vector<int> adj[MAXN]; bool visited[MAXN]; int n, m, mx = 0, curr = 0; void dfs(int node) { visited[node] = true; for (int next : adj[node]) { if (!visited[next]) { curr++; dfs(next); } } } int main() { cin >> n >> m; ...
replace
2
3
2
3
0
p02573
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; using P = pair<int, int>; int main() { int N, M; cin >> N >> M; vector<int> A(M), B(M); vector<vector<int>> f(N); for (int i = 0; i < M; i++) { cin >> A.at(i) >> B.at(i); int a = A.at(i) - 1; int b = ...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; using P = pair<int, int>; int main() { int N, M; cin >> N >> M; vector<int> A(M), B(M); vector<vector<int>> f(N); for (int i = 0; i < M; i++) { cin >> A.at(i) >> B.at(i); int a = A.at(i) - 1; int b = ...
replace
16
22
16
18
TLE
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define pi acos(-1.0) #define pb push_back #define vi vector<int> #define mapii map<int, int> #define mapci map<char, int> #define mapsi map<string, int> #define FOR(i, n) for (int i = 0; i < n; i++) #define CP(n) cout << "Case " << n << ": " #define fr freopen("input.txt",...
#include <bits/stdc++.h> #define ll long long #define pi acos(-1.0) #define pb push_back #define vi vector<int> #define mapii map<int, int> #define mapci map<char, int> #define mapsi map<string, int> #define FOR(i, n) for (int i = 0; i < n; i++) #define CP(n) cout << "Case " << n << ": " #define fr freopen("input.txt",...
replace
29
31
29
33
-11
p02573
C++
Runtime Error
// R<3S #include <bits/stdc++.h> #define hell 1000000007 #define PI 3.14159265358979323844 #define mp make_pair #define pb push_back #define fi first #define se second #define ALL(v) v.begin(), v.end() #define SORT(v) sort(ALL(v)) #define REVERSE(v) reverse(ALL(v)) #define endl "\n" #define vecmax(v) max_element(all(v)...
// R<3S #include <bits/stdc++.h> #define hell 1000000007 #define PI 3.14159265358979323844 #define mp make_pair #define pb push_back #define fi first #define se second #define ALL(v) v.begin(), v.end() #define SORT(v) sort(ALL(v)) #define REVERSE(v) reverse(ALL(v)) #define endl "\n" #define vecmax(v) max_element(all(v)...
replace
35
37
35
37
0
p02573
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define DEBUG(x) cout << #x << "=...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define DEBUG(x) cout << #x << "=...
replace
68
69
68
69
0
p02573
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int MAX = 1000 * 100 + 11; vector<int> a[MAX]; vector<bool> vis(MAX); int n, m; int res = 0, curr = 0; void dfs(int currNode) { if (vis[currNode]) { return; } curr++; vis[currNode] = true; for (auto it : a[currNode]) { dfs(it); } } int main() ...
#include <bits/stdc++.h> using namespace std; const int MAX = 2000 * 100 + 11; vector<int> a[MAX]; vector<bool> vis(MAX); int n, m; int res = 0, curr = 0; void dfs(int currNode) { if (vis[currNode]) { return; } curr++; vis[currNode] = true; for (auto it : a[currNode]) { dfs(it); } } int main() ...
replace
4
5
4
5
0
p02573
C++
Runtime Error
/* 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! ...
replace
188
189
188
189
-11
p02573
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long using namespace std; int root[100010]; // root[i]=i's parent int element[100010]; // element[i]=i's group's element // element[find(i)] is better void init(int n) { for (int i = 0; i < n; i++) root[i] = i, element[i] = 1; } // reset int find(int x) { if (root[x...
#include <bits/stdc++.h> #define ll long long using namespace std; int root[200010]; // root[i]=i's parent int element[200010]; // element[i]=i's group's element // element[find(i)] is better void init(int n) { for (int i = 0; i < n; i++) root[i] = i, element[i] = 1; } // reset int find(int x) { if (root[x...
replace
4
6
4
6
0
p02573
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <vector> #define llong long long #define rep(i, l, n) for (llong(i) = (l); (i) < (n); (i++)) #define _min(a, b) ((a) < (b) ? (a) : (b)) #define _max(a, b) ((a) > (b) ? (a) : (b)) #define _abs(a) ((a) > 0 ? (a) : (-(a))) using namespace...
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <vector> #define llong long long #define rep(i, l, n) for (llong(i) = (l); (i) < (n); (i++)) #define _min(a, b) ((a) < (b) ? (a) : (b)) #define _max(a, b) ((a) > (b) ? (a) : (b)) #define _abs(a) ((a) > 0 ? (a) : (-(a))) using namespace...
replace
22
24
22
27
TLE