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> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int lli; #define int lli typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<lli> vli; typedef vector<pii> vii; typedef tree<int, null_type, less<int>, rb_tree_tag, ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int lli; #define int lli typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<lli> vli; typedef vector<pii> vii; typedef tree<int, null_type, less<int>, rb_tree_tag, ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
825
#include <bits/stdc++.h> using namespace std; #define N 200005 int n, m, i, x, y, pos[N], v[N], ans; queue<int> Q; vector<int> a[N]; int main(void) { scanf("%d%d", &n, &m); for (; m; m--) { scanf("%d%d", &x, &y); a[x].push_back(y); a[y].push_back(x); } Q.push(1), v[1] = 1, pos[1] = -1; while (...
#include <bits/stdc++.h> using namespace std; #define N 200005 int n, m, i, x, y, pos[N], v[N], ans; queue<int> Q; vector<int> a[N]; int main(void) { scanf("%d%d", &n, &m); for (; m; m--) { scanf("%d%d", &x, &y); a[x].push_back(y); a[y].push_back(x); } Q.push(1), v[1] = 1, pos[1] = -1; while (...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
303
from collections import deque N,M = map(int,input().split()) ans = [-1]*(N+1) E = [[] for i in range(N+1)] for i in range(M): a,b = map(int,input().split()) E[a].append(b) E[b].append(a) q = deque([1]) while(q): v = q.popleft() for s in E[v]: if(ans[s] == -1): ans[s] = v ...
from collections import deque N,M = map(int,input().split()) ans = [-1]*(N+1) E = [[] for i in range(N+1)] for i in range(M): a,b = map(int,input().split()) E[a].append(b) E[b].append(a) q = deque([1]) while(q): v = q.popleft() for s in E[v]: if(ans[s] == -1): ans[s] = v ...
[["+", 36, 36, 0, 656, 0, 7, 12, 206, 0, 70], ["+", 0, 656, 0, 7, 12, 206, 206, 663, 0, 612], ["+", 0, 656, 0, 7, 12, 206, 206, 663, 0, 102], ["+", 36, 36, 0, 656, 0, 7, 12, 206, 0, 73]]
5
181
/* #region Head */ #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pll = pair<ll, ll>; template <class T> using vc = vector<T>; template <class T> using vvc = vc<vc<T>>; using vll = vc<ll>; using vvll = vvc<ll>; using vld = vc<ld>; usin...
/* #region Head */ #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pll = pair<ll, ll>; template <class T> using vc = vector<T>; template <class T> using vvc = vc<vc<T>>; using vll = vc<ll>; using vvll = vvc<ll>; using vld = vc<ld>; usin...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
1,854
#include <bits/stdc++.h> using namespace std; const int N = int(2e5 + 10); vector<int> adj[N]; int dis[N]; int father[N]; queue<int> q; void bfs() { dis[1] = 0; q.push(1); while (!q.empty()) { int u = q.front(); q.pop(); for (int v : adj[u]) { if (dis[v] == -1) { father[v] = u; ...
#include <bits/stdc++.h> using namespace std; const int N = int(2e5 + 10); vector<int> adj[N]; int dis[N]; int father[N]; queue<int> q; void bfs() { dis[1] = 0; q.push(1); while (!q.empty()) { int u = q.front(); q.pop(); for (int v : adj[u]) { if (dis[v] == -1) { father[v] = u; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22]]
1
309
#include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> using namespace std; #define endl "\n" #define ll long long #define sz(s) (int)(s.size()) #define INF 0x3f3f3f3f3f3f3f3fLL #define all(v) v.begin(), v.end() #define watch(x) cout << (#x) << " = " << x << endl const int dr[]{-1, -1, 0, 1, 1, 1, 0...
#include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> using namespace std; #define endl "\n" #define ll long long #define sz(s) (int)(s.size()) #define INF 0x3f3f3f3f3f3f3f3fLL #define all(v) v.begin(), v.end() #define watch(x) cout << (#x) << " = " << x << endl const int dr[]{-1, -1, 0, 1, 1, 1, 0...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
464
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265358979323846 #define int long long constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long INFL = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; using Graph = ve...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265358979323846 #define int long long constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long INFL = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; using Graph = ve...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
380
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define F first #define S second #define int long long #define lint long long #define mp make_pair #define pii pair<int, int> #define vi vector<int> #define sz(x) (int)x.size() #define all(x) beg...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define F first #define S second #define int long long #define lint long long #define mp make_pair #define pii pair<int, int> #define vi vector<int> #define sz(x) (int)x.size() #define all(x) beg...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
353
#include <bits/stdc++.h> using namespace std; using Int = long long; #define PUTS(x) cout << (x) << endl; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define PB push_back #define MP make_pair #define MT make_tuple #def...
#include <bits/stdc++.h> using namespace std; using Int = long long; #define PUTS(x) cout << (x) << endl; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define PB push_back #define MP make_pair #define MT make_tuple #def...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
307
n, m = map(int, input().split()) visited = set() my_dict = dict() for i in range(m): a, b = map(int, input().split()) if a in my_dict: my_dict[a].append(b) else: my_dict[a] = [b] if b in my_dict: my_dict[b].append(a) else: my_dict[b] = [a] ret_dict = dict() queue =...
n, m = map(int, input().split()) visited = set() my_dict = dict() for i in range(m): a, b = map(int, input().split()) if a in my_dict: my_dict[a].append(b) else: my_dict[a] = [b] if b in my_dict: my_dict[b].append(a) else: my_dict[b] = [a] ret_dict = dict() queue =...
[["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
186
import sys import math from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN from collections import deque from bisect import bisect_left from itertools import product def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readlin...
import sys import math from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN from collections import deque from bisect import bisect_left from itertools import product def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readlin...
[["-", 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
606
#include <bits/stdc++.h> const long long INF = 1LL << 60; const long long MOD = 1000000007; const double PI = acos(-1.0); #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = (n - 1); i >= 0; --i) #define perm(c) ...
#include <bits/stdc++.h> const long long INF = 1LL << 60; const long long MOD = 1000000007; const double PI = acos(-1.0); #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = (n - 1); i >= 0; --i) #define perm(c) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
1,806
#include <bits/stdc++.h> using namespace std; int N, M; vector<int> adj[100005]; int par[100005], dist[100005]; void BFS() { queue<int> q; q.push(1); memset(dist, 0x3f3f3f3f, sizeof(dist)); dist[1] = 0; while (!q.empty()) { int u = q.front(); q.pop(); for (int v : adj[u]) { if (dist[v] > d...
#include <bits/stdc++.h> using namespace std; int N, M; vector<int> adj[100005]; int par[100005], dist[100005]; void BFS() { queue<int> q; q.push(1); memset(dist, 0x3f3f3f3f, sizeof(dist)); dist[1] = 0; while (!q.empty()) { int u = q.front(); q.pop(); for (int v : adj[u]) { if (dist[v] > d...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
292
#include <algorithm> #include <complex> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define REP(i, m, n) for (int i...
#include <algorithm> #include <complex> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define REP(i, m, n) for (int i...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 338, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 12, 22]]
1
592
#include "bits/stdc++.h" using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<PII> VPII; typedef long long LL; typedef vector<LL> VL; typedef vector<VL> VVL; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; typedef priority_queue...
#include "bits/stdc++.h" using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<PII> VPII; typedef long long LL; typedef vector<LL> VL; typedef vector<VL> VVL; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; typedef priority_queue...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
579
#include <bits/stdc++.h> using namespace std; const int MAXN = 110000; bool vis[MAXN]; int val[MAXN]; list<int> grafo[MAXN]; void bfs() { deque<pair<int, int>> Q; vis[0] = true; Q.push_back({0, -1}); while (!Q.empty()) { auto el = Q.front(); int node = el.first; Q.pop_front(); for (auto adj : gr...
#include <bits/stdc++.h> using namespace std; const int MAXN = 110000; bool vis[MAXN]; int val[MAXN]; list<int> grafo[MAXN]; void bfs() { deque<pair<int, int>> Q; vis[0] = true; Q.push_back({0, -1}); while (!Q.empty()) { auto el = Q.front(); int node = el.first; Q.pop_front(); for (auto adj : gr...
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
300
#include <bits/stdc++.h> using namespace std; #define fore(i, s, e) for (int i = s; i < e; i++) #define SZ(a) ((int)a.size()) #define ALL(a) a.begin(), a.end() #define pb push_back #define fst first #define snd second #define FIN \ ios::sync_with_st...
#include <bits/stdc++.h> using namespace std; #define fore(i, s, e) for (int i = s; i < e; i++) #define SZ(a) ((int)a.size()) #define ALL(a) a.begin(), a.end() #define pb push_back #define fst first #define snd second #define FIN \ ios::sync_with_st...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
310
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define fi first #define se second #define endl '\n' #define y1 holyshit #define all(x) x.begin(), x.end() const int inf = 0x3f3f3f3f; int N, M, ans[200010]; vector<int> edge[200010]; int main() {...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define fi first #define se second #define endl '\n' #define y1 holyshit #define all(x) x.begin(), x.end() const int inf = 0x3f3f3f3f; int N, M, ans[200010]; vector<int> edge[200010]; int main() {...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
259
import sys from collections import deque def input(): return sys.stdin.readline().rstrip() def main(): N, M = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(M)] root = [[] for _ in range(M + 1)] for a, b in AB: root[a].append(b) root[b].append(a) qu...
import sys from collections import deque def input(): return sys.stdin.readline().rstrip() def main(): N, M = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(M)] root = [[] for _ in range(N + 1)] for a, b in AB: root[a].append(b) root[b].append(a) qu...
[["-", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 206, 206, 663, 0, 612], ["+", 0, 652, 3, 4, 0, 206, 206, 663, 0, 612]]
5
233
#include <bits/stdc++.h> #include <iomanip> #include <sstream> #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple #define vi vector<ll> #define qu queue<ll> #define min_3(a, b, c) min(a, min(b, c)) #define max_3(a, b, c) max(a, max(b, c)) #define nout(ans) cout << (ans) << "\n" #define...
#include <bits/stdc++.h> #include <iomanip> #include <sstream> #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple #define vi vector<ll> #define qu queue<ll> #define min_3(a, b, c) min(a, min(b, c)) #define max_3(a, b, c) max(a, max(b, c)) #define nout(ans) cout << (ans) << "\n" #define...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
405
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> graph(n + 1); fo...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> graph(n + 1); fo...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22]]
1
309
import copy n,m = map(int,input().split()) graph = [[] for _ in range(m)] for i in range(m): a,b = map(int,input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) memo = [0]*n now = [[0,0]] nxt = [] done = [False]*n done[0] = True while now: for l in now: for j in graph[l[1]]: ...
import copy n,m = map(int,input().split()) graph = [[] for _ in range(n)] for i in range(m): a,b = map(int,input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) memo = [0]*n now = [[0,0]] nxt = [] done = [False]*n done[0] = True while now: for l in now: for j in graph[l[1]]: ...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["-", 0, 52, 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
236
n, m = map(int, input().split()) graf = [[] for _ in range(n)] for i in range(n): a, b = map(int, input().split()) graf[a-1].append(b-1) graf[b-1].append(a-1) out = [0 for _ in range(n)] out[0] = -1 import queue next_visit = queue.Queue() next_visit.put(0) while not next_visit.empty(): i = next_visit.g...
n, m = map(int, input().split()) graf = [[] for _ in range(n)] for i in range(m): a, b = map(int, input().split()) graf[a-1].append(b-1) graf[b-1].append(a-1) out = [0 for _ in range(n)] out[0] = -1 import queue next_visit = queue.Queue() next_visit.put(0) while not next_visit.empty(): i = next_visi...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
213
#include <algorithm> #include <ctype.h> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <vector> #define ll long long u...
#include <algorithm> #include <ctype.h> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <vector> #define ll long long u...
[["-", 0, 1, 0, 11, 12, 16, 31, 69, 28, 22], ["-", 0, 11, 12, 16, 31, 69, 341, 342, 0, 70], ["-", 0, 11, 12, 16, 31, 69, 341, 342, 0, 73], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
385
#include <bits/stdc++.h> using namespace std; #define ll long long #define mii make_pair<int, int> #define mll make_pair<ll, ll> #define pii pair<int, int> #define pll pair<ll, ll> #define rep(i, a, b) for (int i = a; i < b; ++i) #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mii make_pair<int, int> #define mll make_pair<ll, ll> #define pii pair<int, int> #define pll pair<ll, ll> #define rep(i, a, b) for (int i = a; i < b; ++i) #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl ...
[["-", 0, 1, 0, 11, 12, 16, 31, 69, 28, 22], ["-", 0, 11, 12, 16, 31, 69, 341, 342, 0, 70], ["-", 0, 11, 12, 16, 31, 69, 341, 342, 0, 73]]
1
355
#include <bits/stdc++.h> using ll = long long; using namespace std; ll GCD(ll a, ll b) { return a ? GCD(b % a, a) : b; } int main() { int n, m; cin >> n >> m; vector<int> a(m), b(m); for (int i = 0; i < m; i++) cin >> a[i] >> b[i]; vector<vector<int>> G(n); for (int i = 0; i < n; i++) { G[a[i] - 1]....
#include <bits/stdc++.h> using ll = long long; using namespace std; ll GCD(ll a, ll b) { return a ? GCD(b % a, a) : b; } int main() { int n, m; cin >> n >> m; vector<int> a(m), b(m); for (int i = 0; i < m; i++) cin >> a[i] >> b[i]; vector<vector<int>> G(n); for (int i = 0; i < m; i++) { G[a[i] - 1]....
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
337
#include <bits/stdc++.h> #define F first #define S second using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const int N = 1e5 + 5; int par[N]; bool vis[N]; vector<int> adj[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; while (m--) { int u, ...
#include <bits/stdc++.h> #define F first #define S second using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const int N = 1e5 + 5; int par[N]; bool vis[N]; vector<int> adj[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; while (m--) { int u, ...
[["-", 64, 37, 0, 34, 31, 16, 12, 5, 0, 6], ["+", 64, 37, 0, 34, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
285
N,M = map(int,input().split()) path_list = [] for i in range(M): z = [] path_list.append(z) for i in range(M): A,B = map(int,input().split()) path_list[A-1].append(B) path_list[B-1].append(A) chk = [0] * N def bfs(a,chk,path): queue = [a] while queue: b = queue.pop(0) for i ...
N,M = map(int,input().split()) path_list = [] for i in range(N): z = [] path_list.append(z) for i in range(M): A,B = map(int,input().split()) path_list[A-1].append(B) path_list[B-1].append(A) chk = [0] * N def bfs(a,chk,path): queue = [a] while queue: b = queue.pop(0) for i ...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
220
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) typedef pair<ll, ll> cp2; type...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) typedef pair<ll, ll> cp2; type...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
308
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<long long, long long> P; struct edge { long long to, cost; }; const int inf = 1 << 27; const long long INF = 1LL << 60; const int COMBMAX = 1001001; const long long MOD = 1000000007; #define rep(i, n) for (int i = 0; i < (n); ++i) #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<long long, long long> P; struct edge { long long to, cost; }; const int inf = 1 << 27; const long long INF = 1LL << 60; const int COMBMAX = 1001001; const long long MOD = 1000000007; #define rep(i, n) for (int i = 0; i < (n); ++i) #defin...
[["-", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
699
from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) ans = [-1]*n used = [0]*n used[0] = 1 que = deque() que.appendleft(0) while que: v = que.pop() # print(v)...
from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) ans = [-1]*n used = [0]*n used[0] = 1 que = deque() que.appendleft(0) while que: v = que.pop() # print(v)...
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
188
import sys import collections sys.setrecursionlimit(10**7) INTMAX = 9223372036854775807 INTMIN = -9223372036854775808 DVSR = 1000000007 def POW(x, y): return pow(x, y, DVSR) def INV(x, d=DVSR): return pow(x, d - 2, d) def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d def LI(): return [int(x) for x in input().split()] d...
import sys import collections sys.setrecursionlimit(10**7) INTMAX = 9223372036854775807 INTMIN = -9223372036854775808 DVSR = 1000000007 def POW(x, y): return pow(x, y, DVSR) def INV(x, d=DVSR): return pow(x, d - 2, d) def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d def LI(): return [int(x) for x in input().split()] d...
[["+", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
350
import sys from collections import Counter from collections import deque import math def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) n,m=mp() step=[-1]*(n+1) ans=[-1]*(n+1) edge=[[i] for i in range(n+1)] for i in range(m): ...
import sys from collections import Counter from collections import deque import math def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) n,m=mp() step=[-1]*(n+1) ans=[-1]*(n+1) edge=[[i] for i in range(n+1)] for i in range(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
268
from collections import deque N, M = map(int, input().split()) A = [[] for _ in range(M)] for i in range(M): Am, Bm = map(int, input().split()) Am -= 1 Bm -= 1 A[Am].append(Bm) A[Bm].append(Am) is_visited = [False for _ in range(N)] ans = [0 for _ in range(N)] def bfs(): queue = deque() ...
from collections import deque N, M = map(int, input().split()) A = [[] for _ in range(N)] for i in range(M): Am, Bm = map(int, input().split()) Am -= 1 Bm -= 1 A[Am].append(Bm) A[Bm].append(Am) is_visited = [False for _ in range(N)] ans = [0 for _ in range(N)] def bfs(): queue = deque() ...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]]
5
214
n, m = map(int, input().split()) graph = [[] for _ in range(n+1)] for i in range(m): a, b = map(int, input().split()) graph[a].append(b) graph[b].append(a) # bfs milestone = [0] * (n+1) q = [] q.append(1) while len(q) != 0: for i in graph[q[0]]: if milestone[i] == 0: milestone[i] ...
n, m = map(int, input().split()) graph = [[] for _ in range(n+1)] for i in range(m): a, b = map(int, input().split()) graph[a].append(b) graph[b].append(a) # bfs milestone = [0] * (n+1) q = [] q.append(1) while len(q) != 0: for i in graph[q[0]]: if milestone[i] == 0: milestone[i] ...
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
162
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define vi vector<int> #define ii pair<int, int> #define vli vector<ll> #define graph vector<vector<int>> #define vpi vector<pair<int, int>> #define vpli vector<pair<ll, ll>> #define mp make_pair #define F first #define S second...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define vi vector<int> #define ii pair<int, int> #define vli vector<ll> #define graph vector<vector<int>> #define vpi vector<pair<int, int>> #define vpli vector<pair<ll, ll>> #define mp make_pair #define F first #define S second...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
357
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e5 + 10; int num[maxn]; bool vis[maxn]; vector<int> Edge[maxn]; void addEdge(int a, int b) { Edge[a].push_back(b); Edge[b].push_back(a); } void bfs(int u) { vis[u] = true; queue<int> q; q.push(u); while (!q.empty()) { ...
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e5 + 10; int num[maxn]; bool vis[maxn]; vector<int> Edge[maxn]; void addEdge(int a, int b) { Edge[a].push_back(b); Edge[b].push_back(a); } void bfs(int u) { vis[u] = true; queue<int> q; q.push(u); while (!q.empty()) { ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
391
#include <bits/stdc++.h> using namespace std; #define ll long long int #define rep(i, n) for (int i = 0; i < n; i++) #define repp(i, n) for (int i = 1; i <= n; i++) #define sort(v) sort((v).begin(), (v).end()) #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #define riverse(v) reverse((v...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define rep(i, n) for (int i = 0; i < n; i++) #define repp(i, n) for (int i = 1; i <= n; i++) #define sort(v) sort((v).begin(), (v).end()) #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #define riverse(v) reverse((v...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
406
from collections import deque N, M = map(int, input().split()) graph = [[] for _ in range(M)] for i in range(M): a, b = map(lambda x: int(x)-1, input().split()) graph[a].append(b) graph[b].append(a) #print(graph) queue = deque() seen = [-1] * N steps = [-1] * N steps[0] = 0 parents = [-1] * N queue.append(...
from collections import deque N, M = map(int, input().split()) graph = [[] for _ in range(N)] for i in range(M): a, b = map(lambda x: int(x)-1, input().split()) graph[a].append(b) graph[b].append(a) #print(graph) queue = deque() seen = [-1] * N steps = [-1] * N steps[0] = 0 parents = [-1] * N queue.append(...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]]
5
211
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22]]
1
329
#include <bits/stdc++.h> #ifdef _PRINTDEBUG #include "lib/printdebug.hpp" #else #define printdebug(...) 1 #endif #define I_1000000007 (1000000007) #define I_998244353 (998244353) #define I_INF (1 << 28) #define L_INF (1LL << 60) #define rep(i, n) REP(i, 0, (n)) #define repc(i, n) REPC(i, 0, (n)) #define REP(i, n, m) f...
#include <bits/stdc++.h> #ifdef _PRINTDEBUG #include "lib/printdebug.hpp" #else #define printdebug(...) 1 #endif #define I_1000000007 (1000000007) #define I_998244353 (998244353) #define I_INF (1 << 28) #define L_INF (1LL << 60) #define rep(i, n) REP(i, 0, (n)) #define repc(i, n) REPC(i, 0, (n)) #define REP(i, n, m) f...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
490
N,M = map(int,input().split()) A = [] B = [] for m in range(M): a,b = map(int,input().split()) A.append(a) B.append(b) from collections import defaultdict as ddict route = ddict(list) for i in range(M): route[A[i]].append(B[i]) route[B[i]].append(A[i]) for i in range(1,N+1): if route[i] == []: ...
N,M = map(int,input().split()) A = [] B = [] for m in range(M): a,b = map(int,input().split()) A.append(a) B.append(b) from collections import defaultdict as ddict route = ddict(list) for i in range(M): route[A[i]].append(B[i]) route[B[i]].append(A[i]) for i in range(1,N+1): if route[i] == []: ...
[["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
219
<?php fscanf(STDIN, "%d%d", $n, $m); $ans_list = array_fill(1,$n,PHP_INT_MAX); $count_list = $ans_list; $map = array_fill(1,$n,[]); $ans_list[1] = 0; $count_list[1] = 0; for($i = 0;$i<$m; $i++){ fscanf(STDIN, "%d%d", $a, $b); $map[$a][$b] = 1; $map[$b][$a] = 1; } $queue = []; getQueue($map[1], 1, 1); $i=0...
<?php fscanf(STDIN, "%d%d", $n, $m); $ans_list = array_fill(1,$n,PHP_INT_MAX); $count_list = $ans_list; $map = array_fill(1,$n,[]); $ans_list[1] = 0; $count_list[1] = 0; for($i = 0;$i<$m; $i++){ fscanf(STDIN, "%d%d", $a, $b); $map[$a][$b] = 1; $map[$b][$a] = 1; } $queue = []; getQueue($map[1], 1, 1); $i=0...
[["-", 3, 3, 0, 28, 0, 16, 31, 69, 0, 612], ["+", 3, 3, 0, 28, 0, 16, 31, 69, 0, 612]]
6
429
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> typedef long long ll; using namespace std; void solve() { int n, m; cin >> n >> m; vector<vector<int>> v(n + 1); for (int i = 0; i < m; i++) { int a, b; cin >> a...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> typedef long long ll; using namespace std; void solve() { int n, m; cin >> n >> m; vector<vector<int>> v(n + 1); for (int i = 0; i < m; i++) { int a, b; cin >> a...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
288
import sys from collections import defaultdict, deque sys.setrecursionlimit(10 ** 7) # ---------- INF = float("inf") MOD = 10 ** 9 + 7 # ---------- N, M = map(int, input().split()) G = defaultdict(list) for i in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 G[a].append(b) G[b].append...
import sys from collections import defaultdict, deque sys.setrecursionlimit(10 ** 7) # ---------- INF = float("inf") MOD = 10 ** 9 + 7 # ---------- N, M = map(int, input().split()) G = defaultdict(list) for i in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 G[a].append(b) G[b].append...
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
193
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long const int mod = 1000000007; const ll INF = 1000000000000000000; const double PI =...
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long const int mod = 1000000007; const ll INF = 1000000000000000000; const double PI =...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
281
N,M=map(int,input().split()) P=[[] for i in range(N+1)] for i in range(M): a,b=map(int,input().split()) P[a].append(b) P[b].append(a) #AB=[list(map(int,input().split())) for i in range(M)] ans=[0]*N con=set() now=[1] while now!=[]: _now=[] for n in now: for p in P[n]: if p in con: continue ...
N,M=map(int,input().split()) P=[[] for i in range(N+1)] for i in range(M): a,b=map(int,input().split()) P[a].append(b) P[b].append(a) #AB=[list(map(int,input().split())) for i in range(M)] ans=[0]*N con=set() now=[1] while now!=[]: _now=[] for n in now: for p in P[n]: if p in con: continue ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
163
from collections import deque N,M=map(int,input().split()) tr=[[] for _ in range(N)] for _ in range(M): a,b=map(int,input().split()) tr[a-1].append(b-1) tr[b-1].append(a-1) print(tr) ans=[-1]*N q=deque([0]) v=[True]*N x=[True]*N while q: t=q.popleft() if v[t]: v[t]=False for j in tr[...
from collections import deque N,M=map(int,input().split()) tr=[[] for _ in range(N)] for _ in range(M): a,b=map(int,input().split()) tr[a-1].append(b-1) tr[b-1].append(a-1) ans=[-1]*N q=deque([0]) v=[True]*N x=[True]*N while q: t=q.popleft() if v[t]: v[t]=False for j in tr[t]: ...
[["-", 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
196
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #de...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #de...
[["-", 15, 339, 51, 16, 12, 16, 31, 118, 28, 22], ["+", 51, 16, 12, 16, 31, 118, 28, 69, 28, 22], ["+", 12, 16, 31, 118, 28, 69, 341, 342, 0, 70], ["+", 12, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 118, 28, 69, 341, 342, 0, 73]]
1
691
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define bit(x) (1L << (x)) using ll = long long; using namespace std; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typename... Ts> auto make_v(size_t a, Ts......
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define bit(x) (1L << (x)) using ll = long long; using namespace std; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typename... Ts> auto make_v(size_t a, Ts......
[["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["-", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120]]
1
304
n,m = map(int, input().split()) G = [[]for i in range(n)] for i in range(m): a,b = map(int, input().split()) a,b = a-1,b-1 G[a].append(b) G[b].append(a) from collections import deque def bfs(): heap = deque() road = [0]*n heap.append((0, -1)) used = set() while heap: cur, p...
n,m = map(int, input().split()) G = [[]for i in range(n)] for i in range(m): a,b = map(int, input().split()) a,b = a-1,b-1 G[a].append(b) G[b].append(a) from collections import deque def bfs(): heap = deque() road = [0]*n heap.append((0, -1)) used = set() while heap: cur, p...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
209
#include <bits/stdc++.h> using namespace std; int N, M; int main() { cin >> N >> M; vector<vector<int>> adj(N); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; adj[a].push_back(b); adj[b].push_back(a); } queue<pair<int, int>> q; q.push({0, -1}); vector<int> res(N, ...
#include <bits/stdc++.h> using namespace std; int N, M; int main() { cin >> N >> M; vector<vector<int>> adj(N); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; adj[a].push_back(b); adj[b].push_back(a); } queue<pair<int, int>> q; q.push({0, -1}); vector<int> res(N, ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
250
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> graph(M); vector<int> color(N, -1); for (int i = 0; i < M; i++) { int A, B; cin >> A >> B; A--; B--; graph[A].push_back(B); graph[B].push_back(A); } queue<int> Q; Q.push(0)...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> graph(N); vector<int> color(N, -1); for (int i = 0; i < M; i++) { int A, B; cin >> A >> B; A--; B--; graph[A].push_back(B); graph[B].push_back(A); } queue<int> Q; Q.push(0)...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
284
// Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") // Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> ...
// Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") // Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
638
from collections import deque N , M =[int(hoge) for hoge in input().split()] route = [[] for i in range(N)] for i in range(M): A,B = [int(hoge)-1 for hoge in input().split()] route[A].append(B) route[B].append(A) #全域部分木をほどよく作れるかどうか #BFS queue = deque()#append,popleft went = [-1] * N went[0] = True queue.ap...
from collections import deque N , M =[int(hoge) for hoge in input().split()] route = [[] for i in range(N)] for i in range(M): A,B = [int(hoge)-1 for hoge in input().split()] route[A].append(B) route[B].append(A) #全域部分木をほどよく作れるかどうか #BFS queue = deque()#append,popleft went = [-1] * N went[0] = True queue.ap...
[["+", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
190
class queue: listQ = [] def push(self, x): self.listQ.append(x) def pop(self): a = self.listQ[0] del self.listQ[0] return a def length(self): return len(self.listQ) n, m = map(int, input().split()) nodeMap = {} doneL = [0]*(n+1) doneL[1] = -1 for i in range(m): ...
class queue: listQ = [] def push(self, x): self.listQ.append(x) def pop(self): a = self.listQ[0] del self.listQ[0] return a def length(self): return len(self.listQ) n, m = map(int, input().split()) nodeMap = {} doneL = [0]*(n+1) doneL[1] = -1 for i in range(m): ...
[["-", 0, 7, 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
255
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for (ll i = 0; i < n; i++) #define ll long long #define MOD 1000000007 #define llMAX 9223372036854775807 #define llMIN -9223372036854775808 using vi = vector<ll>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける ll n, m; //...
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for (ll i = 0; i < n; i++) #define ll long long #define MOD 1000000007 #define llMAX 9223372036854775807 #define llMIN -9223372036854775808 using vi = vector<ll>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける ll n, m; //...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
396
#include <bits/stdc++.h> using namespace std; typedef long long lli; typedef long double lld; #define mod 1000000007 #define mod2 998244353 #define fori(n) for (int i = 0; i < n; i++) #define forj(n) for (int j = 0; j < n; j++) #define pb push_back #define mp make_pair #define F first #define S second #define fast ios:...
#include <bits/stdc++.h> using namespace std; typedef long long lli; typedef long double lld; #define mod 1000000007 #define mod2 998244353 #define fori(n) for (int i = 0; i < n; i++) #define forj(n) for (int j = 0; j < n; j++) #define pb push_back #define mp make_pair #define F first #define S second #define fast ios:...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
720
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pli = pair<ll, int>; using pil = pair<int, ll>; using uint = unsigned int; template <typename T> using Graph = vector<vector<T>>; const ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pli = pair<ll, int>; using pil = pair<int, ll>; using uint = unsigned int; template <typename T> using Graph = vector<vector<T>>; const ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
417
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m], b[m]; vector<vector<int>> pas(n); int root[n], check[n] = {}; for (int i = 0; i < m; i++) { cin >> a[i] >> b[i]; pas[a[i] - 1].push_back(b[i] - 1); pas[b[i] - 1].push_back(a[i] - 1); } queue<int> q;...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m], b[m]; vector<vector<int>> pas(n); int root[n], check[n] = {}; for (int i = 0; i < m; i++) { cin >> a[i] >> b[i]; pas[a[i] - 1].push_back(b[i] - 1); pas[b[i] - 1].push_back(a[i] - 1); } queue<int> q;...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
288
import sys from collections import deque readline = sys.stdin.readline N, M = map(int, readline().split()) AB = [list(map(int, readline().split())) for i in range(M)] AB = [(a-1, b-1) for a,b in AB] adj = [[] for i in range(N)] for a,b in AB: adj[a].append(b) adj[b].append(a) ans = [-1] * N q = deque() q.ap...
import sys from collections import deque readline = sys.stdin.readline N, M = map(int, readline().split()) AB = [list(map(int, readline().split())) for i in range(M)] AB = [(a-1, b-1) for a,b in AB] adj = [[] for i in range(N)] for a,b in AB: adj[a].append(b) adj[b].append(a) ans = [-1] * N q = deque() q.ap...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
216
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; // using Graph = vector<vector<edge>>; using dou = long double; string yes = "yes"; string Yes = "Yes"; string YES = "YES"; string no = "no"; string No = "No"; string NO = "NO"; template <class T> inline bool chmax(T &a, T b) { if (a < b) {...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; // using Graph = vector<vector<edge>>; using dou = long double; string yes = "yes"; string Yes = "Yes"; string YES = "YES"; string no = "no"; string No = "No"; string NO = "NO"; template <class T> inline bool chmax(T &a, T b) { if (a < b) {...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
689
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> e(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a; --b; e[a].push_back(b); e[b].push_back(a); } queue<int> q; q.push(0); vector<int> prev(n, -1); prev[0] = 0...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> e(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a; --b; e[a].push_back(b); e[b].push_back(a); } queue<int> q; q.push(0); vector<int> prev(n, -1); prev[0] = 0...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
264
N, M = map(int, input().split()) E = [[] for _ in range(N)] for _ in range(M): A, B = map(int, input().split()) E[A-1] += [B-1] E[B-1] += [A-1] ans = [-1]*N T = [0] while len(T)>0: P = T T = [] for x in P: for e in E[x]: if ans[e]==-1: T += [e] ans[e] = x for a in ans[1:]: print...
N, M = map(int, input().split()) E = [[] for _ in range(N)] for _ in range(M): A, B = map(int, input().split()) E[A-1] += [B-1] E[B-1] += [A-1] ans = [-1]*N T = [0] while len(T)>0: P = T T = [] for x in P: for e in E[x]: if ans[e]==-1: T += [e] ans[e] = x print("Yes") for a in an...
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
153
from sys import stdin, setrecursionlimit input = stdin.buffer.readline setrecursionlimit(10 ** 7) from heapq import heappush, heappop from bisect import bisect_left, bisect_right from collections import deque, defaultdict from itertools import combinations, permutations, combinations_with_replacement from itertools im...
from sys import stdin, setrecursionlimit input = stdin.buffer.readline setrecursionlimit(10 ** 7) from heapq import heappush, heappop from bisect import bisect_left, bisect_right from collections import deque, defaultdict from itertools import combinations, permutations, combinations_with_replacement from itertools im...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]]
5
266
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define db(x) (cerr << #x << ": " << (x) << '\n') #define cps CLOCKS_PER_SEC #define tests(t) \ int t; ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define db(x) (cerr << #x << ": " << (x) << '\n') #define cps CLOCKS_PER_SEC #define tests(t) \ int t; ...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
398
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int INF = 0x3f3f3f3f; vector<int> e[MAXN]; int dis[MAXN], pre[MAXN]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int a, b; scanf("%d%d", &a, &b); e[a].push_back(b); e[b].push_back(a); } ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int INF = 0x3f3f3f3f; vector<int> e[MAXN]; int dis[MAXN], pre[MAXN]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int a, b; scanf("%d%d", &a, &b); e[a].push_back(b); e[b].push_back(a); } ...
[["-", 0, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
308
#include <bits/stdc++.h> #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define pii pair<int, int> #define pll pair<long long, long long> #define all(v) v.begin(), v.end() using namespace std; struct nd { vector<int> ady; } G[100010]; int n, m, cont, u, v, ans[10...
#include <bits/stdc++.h> #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define pii pair<int, int> #define pll pair<long long, long long> #define all(v) v.begin(), v.end() using namespace std; struct nd { vector<int> ady; } G[100010]; int n, m, cont, u, v, ans[10...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
303
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; /*bool compare_function(const pair<int, int> a, const pair<int, int> b) { return a.first ...
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; /*bool compare_function(const pair<int, int> a, const pair<int, int> b) { return a.first ...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
941
from collections import defaultdict from math import gcd def main(): mod = 10 ** 9 + 7 worst_iwashi_count = 0 ans = 1 d = defaultdict(int) N = int(input()) for _ in range(N): a, b = map(int, input().split()) if a == 0 and b == 0: worst_iwashi_count += 1 elif...
from collections import defaultdict from math import gcd def main(): mod = 10 ** 9 + 7 worst_iwashi_count = 0 ans = 1 d = defaultdict(int) N = int(input()) for _ in range(N): a, b = map(int, input().split()) if a == 0 and b == 0: worst_iwashi_count += 1 elif...
[["+", 8, 196, 0, 1, 0, 677, 12, 657, 17, 33], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 12, 612]]
5
302
from math import gcd from collections import defaultdict N = int(input()) MOD = 10 ** 9 + 7 zero_zero_num = 0 fishes = defaultdict(int) for i in range(N): a, b = map(int, input().split()) if a == 0 and b == 0: zero_zero_num += 1 elif a == 0: fishes[(0, -1)] += 1 elif b == 0: fis...
from math import gcd from collections import defaultdict N = int(input()) MOD = 10 ** 9 + 7 zero_zero_num = 0 fishes = defaultdict(int) for i in range(N): a, b = map(int, input().split()) if a == 0 and b == 0: zero_zero_num += 1 elif a == 0: fishes[(0, -1)] += 1 elif b == 0: fis...
[["+", 0, 677, 31, 206, 206, 660, 0, 652, 63, 22], ["+", 31, 206, 206, 660, 0, 652, 3, 4, 0, 24], ["+", 31, 206, 206, 660, 0, 652, 3, 4, 0, 25]]
5
336
import sys input = sys.stdin.readline input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return sys.stdin.read() def II(): return int(input()) def MI(): return map(int,input().split()) def MF(): return map(float,input().split()) def LI(): return list(map(int,in...
import sys input = sys.stdin.readline input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return sys.stdin.read() def II(): return int(input()) def MI(): return map(int,input().split()) def MF(): return map(float,input().split()) def LI(): return list(map(int,in...
[["+", 0, 677, 31, 206, 206, 660, 0, 664, 17, 33]]
5
456
/* [Template].cpp Example code to use when starting new code. This particular problem was problem 977A_Wrong_Subtraction from CodeForces Compile: g++ -o E_Bullet.exe E_Bullet.cpp Execute: ./E_Bullet */ #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostrea...
/* [Template].cpp Example code to use when starting new code. This particular problem was problem 977A_Wrong_Subtraction from CodeForces Compile: g++ -o E_Bullet.exe E_Bullet.cpp Execute: ./E_Bullet */ #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostrea...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]]
1
631
#include <bits/stdc++.h> using namespace std; // macro #define rep(i, n) for (i = 0; i < n; i++) #define ll long long #define all(v) v.begin(), v.end() // code starts typedef pair<ll, ll> P; #define MOD 1000000007 ll pows(ll a, ll b) { ll left = b; ll ans = 1; ll ks = a; while (left > 0) { if (left % 2 =...
#include <bits/stdc++.h> using namespace std; // macro #define rep(i, n) for (i = 0; i < n; i++) #define ll long long #define all(v) v.begin(), v.end() // code starts typedef pair<ll, ll> P; #define MOD 1000000007 ll pows(ll a, ll b) { ll left = b; ll ans = 1; ll ks = a; while (left > 0) { if (left % 2 =...
[["+", 31, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 72]]
1
904
// 5/10 リアルタイム参加 #include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<int>>; // #include <math.h> static const double pi = 3.141592653589793; // using ll = long long; const int mod = 1000000007; // const ...
// 5/10 リアルタイム参加 #include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<int>>; // #include <math.h> static const double pi = 3.141592653589793; // using ll = long long; const int mod = 1000000007; // const ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 11, 31, 118, 17, 131], ["-", 8, 9, 0, 1, 0, 11, 31, 118, 119, 120]]
1
827
require 'set' def get_ints gets.split.map(&:to_i) end def get_int gets.chomp.to_i end MOD = 1000000007 params = [] N = get_int premise = Hash.new(0) additional = 0 result = 1 N.times do a, b = get_ints if a == 0 && b == 0 additional += 1 elsif a == 0 premise[[0, 1]] += 1 elsif b == 0 pre...
require 'set' def get_ints gets.split.map(&:to_i) end def get_int gets.chomp.to_i end MOD = 1000000007 params = [] N = get_int premise = Hash.new(0) additional = 0 result = 1 N.times do a, b = get_ints if a == 0 && b == 0 additional += 1 elsif a == 0 premise[[0, -1]] += 1 elsif b == 0 pr...
[["+", 0, 755, 31, 742, 0, 516, 0, 748, 17, 33]]
4
213
import math def heikatu(A,B): c = math.gcd(A,B) return (A//c,B//c) def pow_r(x, n,mod=10**9+7): """ O(log n) """ if n == 0: # exit case return 1 if n % 2 == 0: # standard case ① n is even return pow_r((x ** 2)%1000000007 , n // 2) % mod else: # standard cas...
import math def heikatu(A,B): c = math.gcd(A,B) return (A//c,B//c) def pow_r(x, n,mod=10**9+7): """ O(log n) """ if n == 0: # exit case return 1 if n % 2 == 0: # standard case ① n is even return pow_r((x ** 2)%1000000007 , n // 2) % mod else: # standard cas...
[["+", 64, 196, 0, 1, 0, 662, 12, 664, 17, 33]]
5
411
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 3e5 + 5, mod = 1e9 + 7; ll add(ll a, ll b) { a = (a + mod) % mod; b = (b + mod) % mod; return (a + b) % mod; } ll mul(ll a, ll b) { a = (a + mod) % mod; b = (b + mod) % mod; return 1LL * a * b % mod; } vector<pair<ll, ll>> v...
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 3e5 + 5, mod = 1e9 + 7; ll add(ll a, ll b) { a = (a + mod) % mod; b = (b + mod) % mod; return (a + b) % mod; } ll mul(ll a, ll b) { a = (a + mod) % mod; b = (b + mod) % mod; return 1LL * a * b % mod; } vector<pair<ll, ll>> v...
[["-", 0, 1, 0, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 16, 12, 2, 3, 4, 0, 22]]
1
716
n = gets.to_i @n = n a = Array.new n b = Array.new n c = {} zerozero = 0 MOD = 1000000007 n.times do |i| _a, _b = gets.split.map(&:to_i) a[i] = _a b[i] = _b if _a == 0 && _b == 0 zerozero += 1 elsif _a == 0 c[[0,1]] ||= 0 c[[0,1]] += 1 elsif _b == 0 c[[1,0]] ||= 0 c[[1,0]] += 1 else ...
n = gets.to_i @n = n a = Array.new n b = Array.new n c = {} zerozero = 0 MOD = 1000000007 n.times do |i| _a, _b = gets.split.map(&:to_i) a[i] = _a b[i] = _b if _a == 0 && _b == 0 zerozero += 1 elsif _a == 0 c[[0,-1]] ||= 0 c[[0,-1]] += 1 elsif _b == 0 c[[1,0]] ||= 0 c[[1,0]] += 1 els...
[["+", 0, 755, 31, 742, 0, 516, 0, 748, 17, 33]]
4
267
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define dofloat cout << fixed << setprecision(8) #define pb push_back #define mp make_pair #define fi first #define se second #define bitcount __builtin_popcount #define all(vec) vec.begin(), vec.end() #define rall(vec) vec.rbeg...
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define dofloat cout << fixed << setprecision(8) #define pb push_back #define mp make_pair #define fi first #define se second #define bitcount __builtin_popcount #define all(vec) vec.begin(), vec.end() #define rall(vec) vec.rbeg...
[["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["-", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 0, 14, 8, 9, 0, 57, 15, 339, 51, 22], ["-", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]]
1
935
#include <bits/stdc++.h> using namespace std; using P = pair<int64_t, int64_t>; int64_t MOD = 1e9 + 7; //繰り返し二乗法 int64_t powmod(int64_t x, int64_t n) { int64_t ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = ans * x; ans %= MOD; } x = x * x; //一周する度にx, x^2, x^4, x^8となる x %= MOD; ...
#include <bits/stdc++.h> using namespace std; using P = pair<int64_t, int64_t>; int64_t MOD = 1e9 + 7; //繰り返し二乗法 int64_t powmod(int64_t x, int64_t n) { int64_t ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = ans * x; ans %= MOD; } x = x * x; //一周する度にx, x^2, x^4, x^8となる x %= MOD; ...
[["-", 8, 9, 0, 57, 75, 76, 0, 57, 0, 121], ["-", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 75, 76, 0, 57, 15, 339, 0, 25]]
1
512
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; using ll = long long; const ll mod = 1e9 + 7; ll power(ll x, ll n, ll M = mod) { ll res = 1; if (n > 0) { res = power(x, n / 2, M); if (n % 2 == 0) res = (res * res) % M; else res = (((res * res) % M)...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; using ll = long long; const ll mod = 1e9 + 7; ll power(ll x, ll n, ll M = mod) { ll res = 1; if (n > 0) { res = power(x, n / 2, M); if (n % 2 == 0) res = (res * res) % M; else res = (((res * res) % M)...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
423
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb emplace_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #defi...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb emplace_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #defi...
[["+", 75, 76, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 75, 76, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 75, 76, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 75, 76, 0, 1, 0, 2, 3, 4, 0, 22]]
1
1,233
import math from collections import Counter MOD = 10**9 + 7 N = int(input()) I = [] zz = 0 sz = 0 tz = 0 for _ in range(N): a,b = map(int, input().split()) # (a, b) = (0, 0) if a == 0 and b == 0: zero += 1 continue # (a, b) = (0, #) if a == 0: sz += 1 continue ...
import math from collections import Counter MOD = 10**9 + 7 N = int(input()) I = [] zz = 0 sz = 0 tz = 0 for _ in range(N): a,b = map(int, input().split()) # (a, b) = (0, 0) if a == 0 and b == 0: zz += 1 continue # (a, b) = (0, #) if a == 0: sz += 1 continue # ...
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22]]
5
281
#include <bits/stdc++.h> using namespace std; using ll = long long; ll GCD(ll a, ll b) { return (b == 0) ? a : GCD(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; map<pair<ll, ll>, pair<ll, ll>> cnt; ll cnt00 = 0; for (ll i = 0; i < N; i++) { ll A, B; cin >> ...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll GCD(ll a, ll b) { return (b == 0) ? a : GCD(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; map<pair<ll, ll>, pair<ll, ll>> cnt; ll cnt00 = 0; for (ll i = 0; i < N; i++) { ll A, B; cin >> ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
383
#include <iostream> #include <map> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const int MAXN = 200010; const int MOD = 1e9 + 7; int n; ll A[MAXN], B[MAXN]; ll gcd(ll x, ll y) { if (x < y) { swap(x, y); } if (y == 0) { return x; } return gcd(y, x % y); } ll modPow(ll x, ll...
#include <iostream> #include <map> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const int MAXN = 200010; const int MOD = 1e9 + 7; int n; ll A[MAXN], B[MAXN]; ll gcd(ll x, ll y) { if (x < y) { swap(x, y); } if (y == 0) { return x; } return gcd(y, x % y); } ll modPow(ll x, ll...
[["-", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
554
/* #include <bits/stdc++.h> */ #include <deque> #include <iostream> #include <unordered_map> #include <vector> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<in...
/* #include <bits/stdc++.h> */ #include <deque> #include <iostream> #include <unordered_map> #include <vector> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<in...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 109], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22]]
1
786
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; #define INF ((1 << 30) - 1) #define L...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; #define INF ((1 << 30) - 1) #define L...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18]]
1
732
# 約分して、互いに素な(1,3) (3,1)のようなペアを作りカウントする # 正のグループと負のグループを別々に管理 # 正のグループの相手が負のグループに存在した場合、 # どちらかのグループから好きなだけ選ぶか、どちらも選ばないかしかない # 誰ともペアにならなかったグループの個数を全て足してP個だとして、2^P通りを掛ける # (0,0)については、その中から1つ選ぶか、選ばないかしかない import sys readline = sys.stdin.readline N = int(readline()) import math zeropair = 0 zeroa = 0 zerob = 0 from coll...
# 約分して、互いに素な(1,3) (3,1)のようなペアを作りカウントする # 正のグループと負のグループを別々に管理 # 正のグループの相手が負のグループに存在した場合、 # どちらかのグループから好きなだけ選ぶか、どちらも選ばないかしかない # 誰ともペアにならなかったグループの個数を全て足してP個だとして、2^P通りを掛ける # (0,0)については、その中から1つ選ぶか、選ばないかしかない import sys readline = sys.stdin.readline N = int(readline()) import math zeropair = 0 zeroa = 0 zerob = 0 from coll...
[["+", 0, 656, 0, 1, 0, 677, 12, 657, 17, 109], ["+", 0, 656, 0, 1, 0, 677, 12, 657, 12, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 109], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 22], ["-", 75, 76, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 12, 22]]
5
324
import collections def gcd(a,b): if b==0: return a else: return gcd(b,a%b) mod=10**9+7 n=int(input()) dic=collections.defaultdict(0) cnt=0 for _ in range(n): a,b=map(int,input().split()) if a!=0 and b!=0: g=gcd(abs(a),abs(b)) if (a>0 and b>0) or (a<0 and b<0): dic[(abs(a)//g,abs(b)//g)]+...
import collections def gcd(a,b): if b==0: return a else: return gcd(b,a%b) mod=10**9+7 n=int(input()) dic=collections.defaultdict(int) cnt=0 for _ in range(n): a,b=map(int,input().split()) if a!=0 and b!=0: g=gcd(abs(a),abs(b)) if (a>0 and b>0) or (a<0 and b<0): dic[(abs(a)//g,abs(b)//g)...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
571
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) mod=10**9+7 n=int(input()) dic={} cnt=0 for _ in range(n): a,b=map(int,input().split()) if a!=0 and b!=0: g=gcd(abs(a),abs(b)) if a*b>0: if (abs(a)//g,abs(b)//g) not in dic: dic[(abs(a)//g,abs(b)//g)]=1 else: di...
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) mod=10**9+7 n=int(input()) dic={} cnt=0 for _ in range(n): a,b=map(int,input().split()) if a!=0 and b!=0: g=gcd(abs(a),abs(b)) if a*b>0: if (abs(a)//g,abs(b)//g) not in dic: dic[(abs(a)//g,abs(b)//g)]=1 else: di...
[["-", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 17, 107]]
5
656
//#pragma GCC optimize ("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/rope> #define pb push_back #define F first #define S second #define ins insert #define...
//#pragma GCC optimize ("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/rope> #define pb push_back #define F first #define S second #define ins insert #define...
[["-", 39, 77, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 39, 77, 39, 344, 3, 347, 0, 77, 39, 40], ["-", 51, 91, 28, 23, 0, 16, 12, 16, 17, 20], ["+", 51, 91, 28, 23, 0, 16, 12, 16, 17, 47]]
1
889
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int NMAX = 2e5 + 10; const int MOD = 1e9 + 7; ll fast_pow(ll a, ll n) { ll ans = 1; while (n) { if (n & 1) ans = ans * a % MOD; a = a * a % MOD; n >>= 1; } return ans; } int main(int argc, char const *argv[]) { map<p...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int NMAX = 2e5 + 10; const int MOD = 1e9 + 7; ll fast_pow(ll a, ll n) { ll ans = 1; while (n) { if (n & 1) ans = ans * a % MOD; a = a * a % MOD; n >>= 1; } return ans; } int main(int argc, char const *argv[]) { map<p...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
506
#include <bits/stdc++.h> using namespace std; #define rep(i, j, k) for (int i = (int)(j); i <= (int)(k); i++) #define debug(x) cerr << #x << ":" << (x) << endl #define fix cout << fixed << setprecision(20); #define int long long const int maxn = (int)1e6 + 5; typedef pair<int, int> pii; #define X first #define Y secon...
#include <bits/stdc++.h> using namespace std; #define rep(i, j, k) for (int i = (int)(j); i <= (int)(k); i++) #define debug(x) cerr << #x << ":" << (x) << endl #define fix cout << fixed << setprecision(20); #define int long long const int maxn = (int)1e6 + 5; typedef pair<int, int> pii; #define X first #define Y secon...
[["+", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
439
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 200200; long long p2[N]; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); p2[0] = 1; for (int i = 1; i < N; i++) { p2[i] = (...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 200200; long long p2[N]; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); p2[0] = 1; for (int i = 1; i < N; i++) { p2[i] = (...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 31, 16,...
1
402
#include <bits/stdc++.h> using namespace std; #define MAXN 200005 #define ll long long map<pair<ll, ll>, pair<ll, ll>> k; const ll mod = 1000000007; ll qpow(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } int main() { // cout<<3...
#include <bits/stdc++.h> using namespace std; #define MAXN 200005 #define ll long long map<pair<ll, ll>, pair<ll, ll>> k; const ll mod = 1000000007; ll qpow(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } int main() { // cout<<3...
[["+", 28, 69, 341, 342, 0, 83, 0, 2, 63, 22], ["+", 341, 342, 0, 83, 0, 2, 3, 4, 0, 24], ["+", 341, 342, 0, 83, 0, 2, 3, 4, 0, 25]]
1
345
MODC = 1000000007 n = gets.strip.to_i z = 0 st = Hash.new{|hash, key| hash[key] = [0,0]} n.times do a,b = gets.strip.split.map(&:to_i) if b == 0 if a == 0 z += 1 else st[0][1] += 1 end else rr = Rational(a,b) if rr >= 0 then st[rr][0] += 1 else st[-1/rr][1] += 1 end end ...
MODC = 1000000007 n = gets.strip.to_i z = 0 st = Hash.new{|hash, key| hash[key] = [0,0]} n.times do a,b = gets.strip.split.map(&:to_i) if b == 0 if a == 0 z += 1 else st[0r][1] += 1 end else rr = Rational(a,b) if rr >= 0 then st[rr][0] += 1 else st[-1/rr][1] += 1 end end...
[["+", 0, 755, 31, 742, 500, 742, 0, 784, 0, 785]]
4
168
n=int(input()) ab=[list(map(int,input().split())) for _ in range(n)] from collections import defaultdict from math import gcd d=defaultdict(int) for a,b in ab: if a==0 and b==0: d[(0,0)]+=1 elif a==0: d[(1,0)]+=1 elif b==0: d[(0,1)]+=1 else: if a<0: a*=-1 b*=-1 g=gcd(a,b) d[(...
n=int(input()) ab=[list(map(int,input().split())) for _ in range(n)] from collections import defaultdict from math import gcd d=defaultdict(int) for a,b in ab: if a==0 and b==0: d[(0,0)]+=1 elif a==0: d[(1,0)]+=1 elif b==0: d[(0,1)]+=1 else: if a<0: a*=-1 b*=-1 g=gcd(a,b) d[(...
[["-", 0, 1, 0, 677, 12, 206, 206, 23, 0, 531], ["+", 0, 1, 0, 677, 12, 206, 206, 660, 0, 612], ["+", 0, 1, 0, 677, 12, 206, 206, 660, 0, 21]]
5
303
#include <algorithm> #include <climits> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long int #define rep(i, n) fo...
#include <algorithm> #include <climits> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long int #define rep(i, n) fo...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
647
#include <bits/stdc++.h> #define FOR(i, a, n) for (int(i) = (int)(a); (i) < (int)(n); ++(i)) #define FORe(i, a, n) for (int(i) = (int)(a); (i) <= (int)(n); ++(i)) #define rFOR(i, a, n) for (int(i) = (int)(n)-1; (i) >= (int)(a); --(i)) #define rFORe(i, a, n) for (int(i) = (int)(n); (i) >= (int)(a); --(i)) #define REP(i,...
#include <bits/stdc++.h> #define FOR(i, a, n) for (int(i) = (int)(a); (i) < (int)(n); ++(i)) #define FORe(i, a, n) for (int(i) = (int)(a); (i) <= (int)(n); ++(i)) #define rFOR(i, a, n) for (int(i) = (int)(n)-1; (i) >= (int)(a); --(i)) #define rFORe(i, a, n) for (int(i) = (int)(n); (i) >= (int)(a); --(i)) #define REP(i,...
[["-", 0, 14, 8, 9, 0, 57, 64, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 1, 0, 34, 0, 21]]
1
907