buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
import java.lang.*; import java.math.BigInteger; import java.util.*; public class Main { // static int ans[]; public static void main(String args[]) { Scanner sc = new Scanner(System.in); String a[] = sc.nextLine().split(" "); int n = Integer.parseInt(a[0]); int m = Integer.parseInt(a[1]); boole...
import java.lang.*; import java.math.BigInteger; import java.util.*; public class Main { // static int ans[]; public static void main(String args[]) { Scanner sc = new Scanner(System.in); String a[] = sc.nextLine().split(" "); int n = Integer.parseInt(a[0]); int m = Integer.parseInt(a[1]); boole...
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 499]]
3
605
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) { Main main = new Main(); main.solve(); } public void solve() { Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); ...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) { Main main = new Main(); main.solve(); } public void solve() { Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); ...
[["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 19]]
3
585
#include <algorithm> #include <iostream> #include <list> #include <queue> using namespace std; int ans[100000]; int main() { int N, M; list<int> e[100000]; cin >> N >> M; 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); } queu...
#include <algorithm> #include <iostream> #include <list> #include <queue> using namespace std; int ans[100000]; int main() { int N, M; list<int> e[100000]; cin >> N >> M; 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); } queu...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
235
#include <cstdio> #include <queue> #include <vector> using namespace std; int main() { int n, m; vector<vector<int>> nodes; vector<int> length; vector<int> parents; scanf("%d%d", &n, &m); nodes.resize(n); length.resize(n); parents.resize(n); for (int i = 0; i < n; ++i) { length[i] = ((i == 0)...
#include <cstdio> #include <queue> #include <vector> using namespace std; int main() { int n, m; vector<vector<int>> nodes; vector<int> length; vector<int> parents; scanf("%d%d", &n, &m); nodes.resize(n); length.resize(n); parents.resize(n); for (int i = 0; i < n; ++i) { length[i] = ((i == 0)...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
335
#include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { int N, M; vector<int> room; vector<vector<int>> path(100001); queue<int> list; room.reserve(100001); cin >> N >> M; vector<int> mark(N + 1, 0); for (int i = 0; i < M; i++) {...
#include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { int N, M; vector<int> room; vector<vector<int>> path(100001); queue<int> list; room.reserve(100001); cin >> N >> M; vector<int> mark(N + 1, 0); for (int i = 0; i < M; i++) {...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 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
262
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < (n); ++i) using namespace std; using i64 = long long; using u64 = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector<vector<int>> adj(N); REP(i, N) {...
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < (n); ++i) using namespace std; using i64 = long long; using u64 = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector<vector<int>> adj(N); REP(i, N) {...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
326
from collections import deque def q4(): class Room: def __init__(self, i): self.id = i self.d = -1 self.next = [] self.sign = -1 def add_next(self, n): self.next.append(n) def print(self, tab=0, printed=[]): if self.i...
from collections import deque def q4(): class Room: def __init__(self, i): self.id = i self.d = -1 self.next = [] self.sign = -1 def add_next(self, n): self.next.append(n) def print(self, tab=0, printed=[]): if self.i...
[["+", 0, 14, 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
353
import static java.lang.Math.*; import java.io.*; import java.util.*; public class Main { public static class pair implements Comparable<pair> { int l; int r; int dif; public pair(int lef, int ri) { l = lef; r = ri; dif = r - l; } @Override public int compareTo(pair...
import static java.lang.Math.*; import java.io.*; import java.util.*; public class Main { public static class pair implements Comparable<pair> { int l; int r; int dif; public pair(int lef, int ri) { l = lef; r = ri; dif = r - l; } @Override public int compareTo(pair...
[["-", 0, 1, 0, 11, 12, 16, 31, 504, 516, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 504, 0, 70], ["-", 0, 1, 0, 11, 12, 16, 31, 504, 0, 73]]
3
950
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> #define ll long long int...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> #define ll long long int...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
368
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define ll long long int main(void) { int n, m; cin >> n >> m; vector<int> a(m), b(m); for (int i = 0; i < m; +...
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define ll long long int main(void) { int n, m; cin >> n >> m; vector<int> a(m), b(m); for (int i = 0; i < m; +...
[["+", 31, 69, 341, 342, 0, 69, 28, 69, 28, 22], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 70], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 22], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 73], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
419
from collections import deque ''' Breadth First Search (BFS) ''' def bfs(x): q = deque([x]) visited[x] = True while q: x = q.popleft() for y in adj[x]: if not visited[y]: q.append(y) visited[y] = True parent[y] = x n, m = map(int,...
from collections import deque ''' Breadth First Search (BFS) ''' def bfs(x): q = deque([x]) visited[x] = True while q: x = q.popleft() for y in adj[x]: if not visited[y]: q.append(y) visited[y] = True parent[y] = x n, m = map(int,...
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 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], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
228
#include <bits/stdc++.h> #include <cmath> using ll = long long; using namespace std; vector<int> arr; stack<int> st; queue<int> qu; queue<pair<int, int>> qu2; priority_queue<int> pq; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, n) for (int i = 1; i <= (int)(n); i++) #define mins(x, y) x = min(x...
#include <bits/stdc++.h> #include <cmath> using ll = long long; using namespace std; vector<int> arr; stack<int> st; queue<int> qu; queue<pair<int, int>> qu2; priority_queue<int> pq; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, n) for (int i = 1; i <= (int)(n); i++) #define mins(x, y) x = min(x...
[["-", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["-", 15, 339, 51, 91, 28, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 91, 28, 2, 63, 118, 28, 22], ["-", 0, 43, 49, 50, 51, 2, 63, 118, 28, 22], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 28, 22], ["-", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120],...
1
616
N, M = list(map(int, input().split())) m = [list() for _ in range(N + 1)] for _ in range(M): A, B = list(map(int, input().split())) m[A].append(B) m[B].append(A) visited = [N + 100 for _ in range(N + 1)] step = 0 visited[1] = step que = [1] os = [0 for _ in range(N + 1)] while len(que) > 0: step += ...
N, M = list(map(int, input().split())) m = [list() for _ in range(N + 1)] for _ in range(M): A, B = list(map(int, input().split())) m[A].append(B) m[B].append(A) visited = [N + 100 for _ in range(N + 1)] step = 0 visited[1] = step que = [1] os = [0 for _ in range(N + 1)] while len(que) > 0: step += ...
[["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
228
from queue import Queue N, M = map(int, input().split()) root = [[] for _ in range(N)] #print(root) for i in range(M): A, B = map(int, input().split()) root[A-1].insert(len(root[A-1]), B) root[B-1].insert(len(root[B-1]), A) room = [0]*N q = Queue() for k in root[0]: room[k-1] = 1 q.put(k) while no...
from queue import Queue N, M = map(int, input().split()) root = [[] for _ in range(N)] #print(root) for i in range(M): A, B = map(int, input().split()) root[A-1].insert(len(root[A-1]), B) root[B-1].insert(len(root[B-1]), A) room = [0]*N q = Queue() for k in root[0]: room[k-1] = 1 q.put(k) while no...
[["+", 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
213
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <numeric> #include <queue> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); ++i) ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <numeric> #include <queue> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); ++i) ...
[["-", 0, 2, 3, 4, 0, 16, 31, 118, 119, 120], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 3, 4, 0, 2, 3, 4, 0, 118, 119, 120], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
371
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); int m = Integer.parseInt(sc.next()); List<List<Integer>> graph = new ArrayList<>(); for (int i = 0; i <= n; i++) { graph.add(new Arr...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); int m = Integer.parseInt(sc.next()); List<List<Integer>> graph = new ArrayList<>(); for (int i = 0; i <= n; i++) { graph.add(new Arr...
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
3
358
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <utility> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; ...
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <utility> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; ...
[["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 69, 28, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
325
from collections import deque n,m = map(int,input().split()) visited = [-1 for _ in range(n)] g = [[] for _ in range(m)] for _ in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) pos = 0 que = deque([]) if g[0]: visited[0] = 0 for nx in g[0]: que.a...
from collections import deque n,m = map(int,input().split()) visited = [-1 for _ in range(n)] 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) pos = 0 que = deque([]) if g[0]: visited[0] = 0 for nx in g[0]: que.a...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]]
5
220
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #define f(i, n) for (int i = 0; i < (n); i++) // here!!! // define int long long !!!!! ...
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #define f(i, n) for (int i = 0; i < (n); i++) // here!!! // define int long long !!!!! ...
[["-", 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
4,524
#include <bits/stdc++.h> using namespace std; vector<int> edge[100010]; int v, e; int par[100010]; bool vis[100010]; int main() { cin >> v >> e; for (int i = 0; i < e; i++) { int a, b; cin >> a >> b; edge[a].push_back(b); edge[b].push_back(a); } queue<int> q; q.push(1); while (!q.empty())...
#include <bits/stdc++.h> using namespace std; vector<int> edge[100010]; int v, e; int par[100010]; bool vis[100010]; int main() { cin >> v >> e; for (int i = 0; i < e; i++) { int a, b; cin >> a >> b; edge[a].push_back(b); edge[b].push_back(a); } queue<int> q; q.push(1); while (!q.empty())...
[["-", 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
283
# # -*- coding: utf-8 -*- # N, M = map(int, input().split(' ')) graph = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split(' ')) a -= 1 b -= 1 graph[a].append(b) graph[b].append(a) # import collections buf = collections.deque() parents = [-1 for _ in range(N)] parents[0] = 0 ...
# # -*- coding: utf-8 -*- # N, M = map(int, input().split(' ')) graph = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split(' ')) a -= 1 b -= 1 graph[a].append(b) graph[b].append(a) # import collections buf = collections.deque() parents = [-1 for _ in range(N)] parents[0] = 0 ...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
201
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int dx[4] = {0,...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int dx[4] = {0,...
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78], ["-", 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
409
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX = 1e5 + 10; int N, M; vector<int> g[MAX]; int ans[MAX], vis[MAX]; queue<int> q; bool bfs() { q.push(1); vis[1] = 1; while (!q.empty()) { int u = q.front(); q.pop(); for (auto &v : g[u]) if (!vis[v]) { ans...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX = 1e5 + 10; int N, M; vector<int> g[MAX]; int ans[MAX], vis[MAX]; queue<int> q; bool bfs() { q.push(1); vis[1] = 1; while (!q.empty()) { int u = q.front(); q.pop(); for (auto &v : g[u]) if (!vis[v]) { ans...
[["-", 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], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
328
def main(): import sys from collections import deque sys.setrecursionlimit(10**6) input = sys.stdin.readline N, M = [int(x) for x in input().strip().split()] G = [deque([]) for _ in range(M)] for m in range(M): a, b = [int(x) for x in input().strip().split()] G[a-1].append(b)...
def main(): import sys from collections import deque sys.setrecursionlimit(10**6) input = sys.stdin.readline N, M = [int(x) for x in input().strip().split()] G = [deque([]) for _ in range(N)] for m in range(M): a, b = [int(x) for x in input().strip().split()] G[a-1].append(b)...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
238
// SmartCoder #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; #define sz(a) int((a).size()) #define pb push_back #define mp make_pair #define all(c) (c).begin(), (c)....
// SmartCoder #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; #define sz(a) int((a).size()) #define pb push_back #define mp make_pair #define all(c) (c).begin(), (c)....
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
1
513
N, M = map(int, input().split()) to = [[] for _ in range(N)] ans = [-1] * N for _ in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) from collections import deque Q = deque([0]) ans[0] = -2 while Q: v = Q.popleft() for s in to[v]: if ans[s]...
N, M = map(int, input().split()) to = [[] for _ in range(N)] ans = [-1] * N for _ in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) from collections import deque Q = deque([0]) ans[0] = -2 while Q: v = Q.popleft() for s in to[v]: if ans[s]...
[["+", 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
166
#include <bits/stdc++.h> #define REP(i, x) REPI(i, 0, x) #define REPI(i, a, b) for (int i = int(a); i < int(b); ++i) #define ALL(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<vector<int>> G(M); i...
#include <bits/stdc++.h> #define REP(i, x) REPI(i, 0, x) #define REPI(i, a, b) for (int i = int(a); i < int(b); ++i) #define ALL(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<vector<int>> G(N); i...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
318
#include <bits/stdc++.h> using namespace std; #define fa(x, v) for (auto x : v) #define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++) #define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--) #define spc " " #define endl '\n' #define ll long long #define pb push_back #define mp make_pair #define ff first #define ss sec...
#include <bits/stdc++.h> using namespace std; #define fa(x, v) for (auto x : v) #define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++) #define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--) #define spc " " #define endl '\n' #define ll long long #define pb push_back #define mp make_pair #define ff first #define ss sec...
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 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
536
#include <bits/stdc++.h> #define pb push_back using namespace std; int n, m, i, x, y, viz[100005], val[100005], nod, nod2, k; vector<int> v[100005]; queue<int> q; int main() { cin >> n >> m; for (i = 1; i <= m; i++) { cin >> x >> y; v[x].pb(y); v[y].pb(x); } q.push(1); viz[1] = 1; while (!q.empt...
#include <bits/stdc++.h> #define pb push_back using namespace std; int n, m, i, x, y, viz[100005], val[100005], nod, nod2, k; vector<int> v[100005]; queue<int> q; int main() { cin >> n >> m; for (i = 1; i <= m; i++) { cin >> x >> y; v[x].pb(y); v[y].pb(x); } q.push(1); viz[1] = 1; while (!q.empt...
[["-", 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], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
265
#define taskname "test" #include <bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define fi first #define se second typedef long long lli; typedef pair<int, int> pii; const int maxn = 2e5 + 5; int n, m; vector<int> gr[maxn]; int p[maxn]; bool vis[maxn]; void read_input() { cin >> n >> m; fo...
#define taskname "test" #include <bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define fi first #define se second typedef long long lli; typedef pair<int, int> pii; const int maxn = 2e5 + 5; int n, m; vector<int> gr[maxn]; int p[maxn]; bool vis[maxn]; void read_input() { cin >> n >> m; fo...
[["-", 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
330
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define mem(x, y) \ memset(x, y, ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define mem(x, y) \ memset(x, y, ...
[["-", 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
584
from collections import deque n, m = map(int, input().split()) g = [[] for i in range(m)] for i in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) dist = [-1] * n prev = [-1] * n que = deque([0]) dist[0] = 0 while que: v = que.popleft() d = dist[v] ...
from collections import deque n, m = map(int, input().split()) g = [[] for i in range(n)] for i in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) dist = [-1] * n prev = [-1] * n que = deque([0]) dist[0] = 0 while que: v = que.popleft() d = dist[v] ...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]]
5
186
from collections import deque n, m = list(map(int, input().split())) al = [0] * n bl = [0] * n G = [[] for _ in range(n)] for i in range(n): a, b = map(int, input().split()) G[a-1].append(b-1) G[b-1].append(a-1) N = n # G[v]: 頂点vに隣接する頂点list # N: 頂点数 dist = [-1]*N tag = [-1]*N que = deque([0]) dist[0] = 0 p...
from collections import deque n, m = list(map(int, input().split())) al = [0] * n bl = [0] * n G = [[] for _ in range(n)] for i in range(m): a, b = map(int, input().split()) G[a-1].append(b-1) G[b-1].append(a-1) N = n # G[v]: 頂点vに隣接する頂点list # N: 頂点数 dist = [-1]*N tag = [-1]*N que = deque([0]) dist[0] = 0 p...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
213
#include <bits/stdc++.h> using namespace std; #define arep(i, x, n) for (int i = int(x); i < (int)(n); i++) #define rep(i, n) for (long long i = 0; i < n; ++i) #define pi 3.141592653589793 #define eps 0.00000001 #define INF 1e9 + 7 using ll = long long; using P = pair<int, int>; using lP = pair<ll, ll>; using fP = pair...
#include <bits/stdc++.h> using namespace std; #define arep(i, x, n) for (int i = int(x); i < (int)(n); i++) #define rep(i, n) for (long long i = 0; i < n; ++i) #define pi 3.141592653589793 #define eps 0.00000001 #define INF 1e9 + 7 using ll = long long; using P = pair<int, int>; using lP = pair<ll, ll>; using fP = pair...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
341
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = a; i < b; i++) #define FORS(i, a, b, c) for (int i = a; i < b; i += c) #define FORN(i, a, b) for (int i = a; i <= b; i++) #define FORD(i, a, b) for (int i = a - 1; i >= b; i--) #define FORE(i, b) for (auto &i : b) #define REP(i, b) FOR(i, ...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = a; i < b; i++) #define FORS(i, a, b, c) for (int i = a; i < b; i += c) #define FORN(i, a, b) for (int i = a; i <= b; i++) #define FORD(i, a, b) for (int i = a - 1; i >= b; i--) #define FORE(i, b) for (auto &i : b) #define REP(i, b) FOR(i, ...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]]
1
548
from collections import deque N, M = map(int, input().split()) Gs = [[] for _ in range(N+1)] for _ in range(M): a, b = map(int, input().split()) Gs[a].append(b) Gs[b].append(a) ms = [0] * (N+1) def bfs(c): queue = deque() ns = Gs[c] for n in ns: queue.append((n, c)) while queue: ...
from collections import deque N, M = map(int, input().split()) Gs = [[] for _ in range(N+1)] for _ in range(M): a, b = map(int, input().split()) Gs[a].append(b) Gs[b].append(a) ms = [0] * (N+1) def bfs(c): queue = deque() ns = Gs[c] for n in ns: queue.append((n, c)) while queue: ...
[["-", 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
223
#include <bits/stdc++.h> #include <cassert> using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; typedef tree< int, null_type, le...
#include <bits/stdc++.h> #include <cassert> using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; typedef tree< int, null_type, le...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
327
require 'pp' n, m = gets.split.map(&:to_i) pathes = Array.new(m) graph = {} m.times do |i| a, b = gets.split.map(&:to_i) pathes[i] = [a, b] graph[a] ||= {} graph[b] ||= {} graph[a][b] = 1 graph[b][a] = 1 end visited = Array.new(n + 1, -1) visited[1] = 0 queue = graph[1].map {|k, _| visited[k] ...
require 'pp' n, m = gets.split.map(&:to_i) pathes = Array.new(m) graph = {} m.times do |i| a, b = gets.split.map(&:to_i) pathes[i] = [a, b] graph[a] ||= {} graph[b] ||= {} graph[a][b] = 1 graph[b][a] = 1 end visited = Array.new(n + 1, -1) visited[1] = 0 queue = graph[1].map {|k, _| visited[k] ...
[["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 62], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6]]
4
208
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long #define endl "\n" #define pii pair<int, int> #define ff first #define ss second #define mii map<int, int> #define si set<int> #define sti stack<int> #define qi queue<int> #define vi vector<int> #define pq priority_queue<int> #defin...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long #define endl "\n" #define pii pair<int, int> #define ff first #define ss second #define mii map<int, int> #define si set<int> #define sti stack<int> #define qi queue<int> #define vi vector<int> #define pq priority_queue<int> #defin...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
303
import itertools from collections import defaultdict import collections import math import sys import queue sys.setrecursionlimit(200000) mod = 1000000007 n, m = map(int, input().split()) graph = {i: [] for i in range(1, m + 1)} for _ in range(m): u, v = map(int, input().split()) graph[u].append(v) graph[...
import itertools from collections import defaultdict import collections import math import sys import queue sys.setrecursionlimit(200000) mod = 1000000007 n, m = map(int, input().split()) graph = {i: [] for i in range(1, n + 1)} for _ in range(m): u, v = map(int, input().split()) graph[u].append(v) graph[...
[["-", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22]]
5
281
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <queue> #include <vector> struct edge { int from; int to; }; int main() { // input int N, M; int A[200000], B[200000]; scanf("%d %d", &N, &M); for (int i = 0; i < M; i++) { scanf("%d %d", A + i, B + i); } // 隣接リ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <queue> #include <vector> struct edge { int from; int to; }; int main() { // input int N, M; int A[200000], B[200000]; scanf("%d %d", &N, &M); for (int i = 0; i < M; i++) { scanf("%d %d", A + i, B + i); } // 隣接リ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
376
# -*- coding: utf-8 -*- from collections import Counter, defaultdict, deque import sys # sys.setrecursionlimit(10**6) # buff_readline = sys.stdin.buffer.readline buff_readline = sys.stdin.readline readline = sys.stdin.readline INF = 2**62-1 def read_int(): return int(buff_readline()) def read_int_n(): r...
# -*- coding: utf-8 -*- from collections import Counter, defaultdict, deque import sys # sys.setrecursionlimit(10**6) # buff_readline = sys.stdin.buffer.readline buff_readline = sys.stdin.readline readline = sys.stdin.readline INF = 2**62-1 def read_int(): return int(buff_readline()) def read_int_n(): r...
[["+", 0, 652, 3, 4, 0, 652, 63, 661, 0, 48]]
5
396
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> using namespace std; vector<int> edge[100001]; int ans[100001]; int n, m; void adde() { int from, to; cin >> from >> to; edge[to].emplace_back(from); edge[from].emplace_b...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> using namespace std; vector<int> edge[100001]; int ans[100001]; int n, m; void adde() { int from, to; cin >> from >> to; edge[to].emplace_back(from); edge[from].emplace_b...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]]
1
277
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "dump.hpp" #else #define dump(...) #define dumpv(...) #endif #define rep(i, n) for (int i = 0; i < (n); i++) #define mins(x, y) (x = min(x, y)) #define maxs(x, y) (x = max(x, y)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; us...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "dump.hpp" #else #define dump(...) #define dumpv(...) #endif #define rep(i, n) for (int i = 0; i < (n); i++) #define mins(x, y) (x = min(x, y)) #define maxs(x, y) (x = max(x, y)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; us...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19]]
1
420
/** * @brief : c++ code for AtCoder * @author : rk222 * @created: 2020.05.17 20:39:39 */ #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector>...
/** * @brief : c++ code for AtCoder * @author : rk222 * @created: 2020.05.17 20:39:39 */ #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector>...
[["-", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120]]
1
1,561
from collections import deque N, M = map(int, input().split()) path = [[] for i in range(N)] indicator = [None] * N indicator[0] = (0, 0) for i in range(M): a, b = map(int, input().split()) a-=1 b-=1 path[a].append(b) path[b].append(a) def solve(N, path, indicator): visit = [False]*N visit...
from collections import deque N, M = map(int, input().split()) path = [[] for i in range(N)] indicator = [None] * N indicator[0] = (0, 0) for i in range(M): a, b = map(int, input().split()) a-=1 b-=1 path[a].append(b) path[b].append(a) def solve(N, path, indicator): visit = [False]*N visit...
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
272
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; const long long MOD = (long long)1e9 + 7; int main() { int n, m, ans = 0; cin >> n >> m; vector<vector<int>> e(m); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; const long long MOD = (long long)1e9 + 7; int main() { int n, m, ans = 0; cin >> n >> m; vector<vector<int>> e(n); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; ...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
311
from collections import deque import sys sys.setrecursionlimit(10**7) N,M=map(int,input().split()) A=[] B=[] road=[[] for i in range(N)] for i in range(N): a,b=map(int,input().split()) road[a-1].append(b-1) road[b-1].append(a-1) visit=[0]*N q=deque([0]) ans=[0]*N visit[0]=1 def bfs(q): while(q): v=q.poplef...
from collections import deque import sys sys.setrecursionlimit(10**7) N,M=map(int,input().split()) A=[] B=[] road=[[] for i in range(N)] for i in range(M): a,b=map(int,input().split()) road[a-1].append(b-1) road[b-1].append(a-1) visit=[0]*N q=deque([0]) ans=[0]*N visit[0]=1 def bfs(q): while(q): v=q.poplef...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
217
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <u...
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <u...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
860
#include <bits/stdc++.h> #define fo(i, a, b) for ((i) = (a); i <= (b); i++) #define rfo(i, a, b) for ((i) = (a); i >= (b); i--) #define inrange(x, y, z) (((x) >= (y)) && ((x) <= (z))) #define ALL(vec) ((vec).begin(), (vec).end()) #define SOR(vec) sort(ALL(vec)) #define UNI(vec) (vec).erase(unique(ALL(vec)), (vec).end()...
#include <bits/stdc++.h> #define fo(i, a, b) for ((i) = (a); i <= (b); i++) #define rfo(i, a, b) for ((i) = (a); i >= (b); i--) #define inrange(x, y, z) (((x) >= (y)) && ((x) <= (z))) #define ALL(vec) ((vec).begin(), (vec).end()) #define SOR(vec) sort(ALL(vec)) #define UNI(vec) (vec).erase(unique(ALL(vec)), (vec).end()...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
347
from collections import deque N, M = map(int, input().split()) graph = {i+1:[] for i in range(N)} for i in range(M): a, b = map(int, input().split()) graph[a].append(b) graph[b].append(a) num = [0 for _ in range(N)] num[0] = 1 dist = [10**15 for _ in range(N)] dist[0] = 0 queue = deque([1]) visited = [...
from collections import deque N, M = map(int, input().split()) graph = {i+1:[] for i in range(N)} for i in range(M): a, b = map(int, input().split()) graph[a].append(b) graph[b].append(a) num = [0 for _ in range(N)] num[0] = 1 dist = [10**15 for _ in range(N)] dist[0] = 0 queue = deque([1]) visited = [...
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
275
// C++(Clang 10.0.0) // GCC用 ナゾです //#pragma GCC target("avx") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include <algorithm> #include <cassert> //assert(x>=0) -> x<0の時異常終了 #include <cmath> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <nume...
// C++(Clang 10.0.0) // GCC用 ナゾです //#pragma GCC target("avx") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include <algorithm> #include <cassert> //assert(x>=0) -> x<0の時異常終了 #include <cmath> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <nume...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22]]
1
1,239
n,m = gets.split.map(&:to_i) g = Array.new(n+1){[]} m.times do f,t = gets.split.map(&:to_i) g[f].push t g[t].push f end ans = Array.new(n+1) ans[0] = ans[1] = 0 queue = [] queue.push [1, g[1]] while !queue.empty? do from, nexts = queue.shift nexts.each do |nex| next if ans[nex] ans[nex] = from ...
n,m = gets.split.map(&:to_i) g = Array.new(n+1){[]} m.times do f,t = gets.split.map(&:to_i) g[f].push t g[t].push f end ans = Array.new(n+1) ans[0] = ans[1] = 0 queue = [] queue.push [1, g[1]] while !queue.empty? do from, nexts = queue.shift nexts.each do |nex| next if ans[nex] ans[nex] = from...
[["+", 0, 493, 0, 121, 75, 95, 0, 652, 735, 22], ["+", 75, 95, 0, 652, 3, 4, 0, 557, 0, 62], ["+", 75, 95, 0, 652, 3, 4, 0, 557, 0, 6]]
4
171
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i <= b; i++) #define per(i, a, b) for (int i = a; i >= b; i--) #define rusha \ scanf("%d", &n); \ rep(i, 1, n) scanf("%d", &a[i])...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i <= b; i++) #define per(i, a, b) for (int i = a; i >= b; i--) #define rusha \ scanf("%d", &n); \ rep(i, 1, n) scanf("%d", &a[i])...
[["-", 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], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
527
#include <bits/stdc++.h> using namespace std; #define INIT \ ios_base ::sync_with_stdio(0); \ cin.tie(); \ cout.tie(); ...
#include <bits/stdc++.h> using namespace std; #define INIT \ ios_base ::sync_with_stdio(0); \ cin.tie(); \ cout.tie(); ...
[["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
288
n,edge = map(int,input().split()) l = [0]*n stack = [1] dic = {} for i in range (edge) : x = [int(x) for x in input().split()] if x[0] not in dic : dic[x[0]] = [] if x[1] not in dic : dic[x[1]] = [] dic[x[0]].append(x[1]) dic[x[1]].append(x[0]) x = 1 while len(stack) != 0 : ch...
n,edge = map(int,input().split()) l = [0]*n stack = [1] dic = {} for i in range (edge) : x = [int(x) for x in input().split()] if x[0] not in dic : dic[x[0]] = [] if x[1] not in dic : dic[x[1]] = [] dic[x[0]].append(x[1]) dic[x[1]].append(x[0]) x = 1 while len(stack) != 0 : ch...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
249
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int ll; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int ll; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) ...
[["+", 0, 2, 3, 4, 0, 69, 28, 69, 28, 22], ["+", 3, 4, 0, 69, 28, 69, 341, 342, 0, 70], ["+", 3, 4, 0, 69, 28, 69, 341, 342, 0, 73], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
556
#import re import sys input = sys.stdin.readline #import heapq #import bisect from collections import deque #import math def main(): n, m = map(int, input().split()) AL = [[] for i in range(n+1)] check = [0 for i in range(n+1)] for i in range(m): s, e = map(int, input().split()) AL[s].a...
#import re import sys input = sys.stdin.readline #import heapq #import bisect from collections import deque #import math def main(): n, m = map(int, input().split()) AL = [[] for i in range(n+1)] check = [0 for i in range(n+1)] for i in range(m): s, e = map(int, input().split()) AL[s].a...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
255
n,m=map(int,input().split()) r=list() for i in range(m): a=list() r.append(a) a=list() for i in range(n): a.append(-1) for i in range(m): x=0;y=0 x,y=map(int,input().split()) x-=1 y-=1 r[x].append(y) r[y].append(x) a[0]=0 now=[0] while len(now)!=0: nex=list() for i i...
n,m=map(int,input().split()) r=list() for i in range(n): a=list() r.append(a) a=list() for i in range(n): a.append(-1) for i in range(m): x=0;y=0 x,y=map(int,input().split()) x-=1 y-=1 r[x].append(y) r[y].append(x) a[0]=0 now=[0] while len(now)!=0: nex=list() for i i...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
211
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < n; i++) #define REP(i, s, n) for (long long i = (s); i <= (n); i++) #define repr(i, n) for (long long i = n - 1; i >= 0; i--) #define REPR(i, s, n) for (long long i = (s); i >= (n); i--) #define all(a) (a).begin(), (a).end() #def...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < n; i++) #define REP(i, s, n) for (long long i = (s); i <= (n); i++) #define repr(i, n) for (long long i = n - 1; i >= 0; i--) #define REPR(i, s, n) for (long long i = (s); i >= (n); i--) #define all(a) (a).begin(), (a).end() #def...
[["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
1,286
#include <bits/stdc++.h> using namespace std; int n, m, ans = 0; // n頂点 m辺 vector<vector<int>> g; vector<int> dis, p; queue<int> q; vector<int> seen; int main() { cin >> n >> m; g.resize(n + 1); dis.resize(n + 1, 9999999); p.resize(n + 1, 9999999); seen.resize(n + 1, 0); for (int i = 0; i < m; i++) { ...
#include <bits/stdc++.h> using namespace std; int n, m, ans = 0; // n頂点 m辺 vector<vector<int>> g; vector<int> dis, p; queue<int> q; vector<int> seen; int main() { cin >> n >> m; g.resize(n + 1); dis.resize(n + 1, 9999999); p.resize(n + 1, 9999999); seen.resize(n + 1, 0); for (int i = 0; i < m; i++) { ...
[["-", 8, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 8, 1, 0, 16, 31, 16, 12, 69, 28, 22]]
1
383
#include <bits/stdc++.h> using namespace std; #define PI 3.1415926535897 int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, m; cin >> n >> m; vector<int> adj[n + 1]; for (int i = 0; i < m; i++) { int...
#include <bits/stdc++.h> using namespace std; #define PI 3.1415926535897 int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, m; cin >> n >> m; vector<int> adj[n + 1]; for (int i = 0; i < m; i++) { int...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
297
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int N, M, a, b, p, nxt; cin >> N >> M; queue<int> q, next_pos; vector<queue<int>> G(M); vector<int> done(N, 0); for (int i = 0; i < M; i++) { cin >> a >> b; G[a - 1].emplace(b - 1); G[b - 1].emplace(a - 1); } ...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int N, M, a, b, p, nxt; cin >> N >> M; queue<int> q, next_pos; vector<queue<int>> G(N); vector<int> done(N, 0); for (int i = 0; i < M; i++) { cin >> a >> b; G[a - 1].emplace(b - 1); G[b - 1].emplace(a - 1); } ...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
248
import collections def get_input(): return list(map(lambda x:int(x), input().split())) def main(): inp = get_input() n, m = inp[0], inp[1] adj_list = [[] for i in range(n)] for i in range(m): inpu = get_input() a, b = inpu[0], inpu[1] adj_list[a - 1].append(b - 1) a...
import collections def get_input(): return list(map(lambda x:int(x), input().split())) def main(): inp = get_input() n, m = inp[0], inp[1] adj_list = [[] for i in range(n)] for i in range(m): inpu = get_input() a, b = inpu[0], inpu[1] adj_list[a - 1].append(b - 1) a...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
258
//#define _GLIBCXX_DEBUG #include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() using namespace std; using Graph = vector<vector<int>>; typedef long long ll; const int mod = 1e+9 + 7; int main() { ll n, m; cin >> n >> m; Graph G(m); r...
//#define _GLIBCXX_DEBUG #include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() using namespace std; using Graph = vector<vector<int>>; typedef long long ll; const int mod = 1e+9 + 7; int main() { ll n, m; cin >> n >> m; Graph G(n); r...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
262
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys...
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys...
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
458
#include <bits/stdc++.h> using namespace std; struct node { vector<int> cld; int dis; bool vis; node() { dis = 1e7 + 7; vis = 0; } } a[100005]; int n, m; int main() { cin >> n >> m; for (int i = 0; i < m; i++) { int aa, b; cin >> aa >> b; a[aa].cld.push_back(b); a[b].cld.push_b...
#include <bits/stdc++.h> using namespace std; struct node { vector<int> cld; int dis; bool vis; node() { dis = 1e7 + 7; vis = 0; } } a[100005]; int n, m; int main() { cin >> n >> m; for (int i = 0; i < m; i++) { int aa, b; cin >> aa >> b; a[aa].cld.push_back(b); a[b].cld.push_b...
[["-", 0, 2, 3, 4, 0, 83, 0, 16, 31, 22], ["-", 0, 2, 3, 4, 0, 83, 0, 16, 17, 72], ["-", 0, 2, 3, 4, 0, 83, 0, 16, 12, 13], ["+", 64, 1, 0, 2, 3, 4, 0, 83, 0, 22]]
1
328
# -*- coding: utf-8 -*- """ Created on Sun May 17 20:56:20 2020 @author: Kanaru Sato """ import collections n,m = list(map(int,input().split())) connected = [[]for i in range(n+1)] for i in range(m): a,b = list(map(int,input().split())) connected[a].append(b) connected[b].append(a) distance = [-1,0] for ...
# -*- coding: utf-8 -*- """ Created on Sun May 17 20:56:20 2020 @author: Kanaru Sato """ import collections n,m = list(map(int,input().split())) connected = [[]for i in range(n+1)] for i in range(m): a,b = list(map(int,input().split())) connected[a].append(b) connected[b].append(a) distance = [-1,0] for ...
[["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
238
#include <bits/stdc++.h> using namespace std; #define ll long long #define LI list<int> #define vct vector #define vi vct<int> #define pii pair<int, int> #define pll pair<ll, ll> #define vvi vct<vi> #define vll vct<ll> #define vvll vct<vll> #define all(a) a.begin(), a.end() #define mp(a, b) make_pair(a, b) #define pb p...
#include <bits/stdc++.h> using namespace std; #define ll long long #define LI list<int> #define vct vector #define vi vct<int> #define pii pair<int, int> #define pll pair<ll, ll> #define vvi vct<vi> #define vll vct<ll> #define vvll vct<vll> #define all(a) a.begin(), a.end() #define mp(a, b) make_pair(a, b) #define pb p...
[["-", 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], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
352
//#include "stdafx.h" #include "algorithm" #include "bitset" #include "chrono" #include "cmath" #include "complex" #include "cstring" #include "deque" #include "fstream" #include "iomanip" #include "iostream" #include "iterator" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #inclu...
//#include "stdafx.h" #include "algorithm" #include "bitset" #include "chrono" #include "cmath" #include "complex" #include "cstring" #include "deque" #include "fstream" #include "iomanip" #include "iostream" #include "iterator" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #inclu...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
580
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef long long ll; typedef vector...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef long long ll; typedef vector...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
488
#include <bits/stdc++.h> using namespace std; #define ll long long int #define vll vector<long long int> #define vi vector<int> #define vpi vector<pair<int, int>> #define PR fixed << setprecision(10) #define set(x) __builtin_popcount(x) #define ffs(x) __builtin_ffs(x) #define clz(x) __builtin_clz(x) #define all(v) v.be...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define vll vector<long long int> #define vi vector<int> #define vpi vector<pair<int, int>> #define PR fixed << setprecision(10) #define set(x) __builtin_popcount(x) #define ffs(x) __builtin_ffs(x) #define clz(x) __builtin_clz(x) #define all(v) v.be...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
368
N, M = [int(i) for i in input().split()] Mark = [0 for _ in range(N+1)] path = {k: [] for k in range(1, N+1)} for i in range(M): A, B = [int(i) for i in input().split()] path[A].append(B) path[B].append(A) next = [1] while True: n = next.pop() for x in path[n]: # n -> x if Mark[x] =...
N, M = [int(i) for i in input().split()] Mark = [0 for _ in range(N+1)] path = {k: [] for k in range(1, N+1)} for i in range(M): A, B = [int(i) for i in input().split()] path[A].append(B) path[B].append(A) next = [1] while True: n = next.pop(0) for x in path[n]: # n -> x if Mark[x] ...
[["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
195
#include <bits/stdc++.h> using namespace std; // in-short-use macros #define all(c) (c).begin(), (c).end() #define ll long long int #define ld long double #define pb push_back #define mp make_pair #define ff first #define ss second #define mod 1000000007 #define PI 3.14159265 #define sizes 100010 // main function he...
#include <bits/stdc++.h> using namespace std; // in-short-use macros #define all(c) (c).begin(), (c).end() #define ll long long int #define ld long double #define pb push_back #define mp make_pair #define ff first #define ss second #define mod 1000000007 #define PI 3.14159265 #define sizes 100010 // main function he...
[["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 8, 9, 0, 57, 64, 1, 0, 34, 0, 21], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 0, 57, 64, 1, 0, 34, 12, 34, 0, 21], ["-", 64, 1, 0, 34, 12, 34, 12, 34, 0, 21], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, ...
1
374
#include <bits/stdc++.h> #define ll long long #define MODV 1000000007 #define INF INT_MAX // 2147483647 #define INFLL LLONG_MAX // 9223372036854775807 #define rep(i, n) for (ll i = 0, i##_len = (ll)(n); i < i##_len; i++) #define repf(i, n) for (ll i = 1, i##_len = (ll)(n + 1); i < i##_len; i++) #define per(i, n) fo...
#include <bits/stdc++.h> #define ll long long #define MODV 1000000007 #define INF INT_MAX // 2147483647 #define INFLL LLONG_MAX // 9223372036854775807 #define rep(i, n) for (ll i = 0, i##_len = (ll)(n); i < i##_len; i++) #define repf(i, n) for (ll i = 1, i##_len = (ll)(n + 1); i < i##_len; i++) #define per(i, n) fo...
[["-", 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
460
#include <bits/stdc++.h> using namespace std; vector<int> edges[100005]; vector<int> parent(100005); void BFS(int s, int V) { bool *visited = new bool[V + 1]; for (int i = 1; i <= V; i++) visited[i] = false; list<int> queue; visited[s] = true; queue.push_back(s); while (!queue.empty()) { s = queu...
#include <bits/stdc++.h> using namespace std; vector<int> edges[100005]; vector<int> parent(100005); void BFS(int s, int V) { bool *visited = new bool[V + 1]; for (int i = 1; i <= V; i++) visited[i] = false; list<int> queue; visited[s] = true; queue.push_back(s); while (!queue.empty()) { s = queu...
[["-", 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
329
#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>; int main() { int n, m; cin >> n >> m; vector<vector<int>> to(m); rep(i, m) { int a, b; cin >> a >> b; a--; b--; to[a].push_back(b); to[b].push_ba...
#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>; int main() { int n, m; cin >> n >> m; vector<vector<int>> to(n); rep(i, m) { int a, b; cin >> a >> b; a--; b--; to[a].push_back(b); to[b].push_ba...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
287
n,m,*ab=map(int,open(0).read().split()) path={} for i in range(n): path[i]=[] for i in range(m): a,b=ab[i*2]-1,ab[i*2+1]-1 path[a].append(b) path[b].append(a) direction=[i for i in range(n)] fin=[False for i in range(n)] fin[0]=True i=0 queue=[0] while i<n: i+=1 queue2=queue.copy() queue.clear() if len(...
n,m,*ab=map(int,open(0).read().split()) path={} for i in range(n): path[i]=[] for i in range(m): a,b=ab[i*2]-1,ab[i*2+1]-1 path[a].append(b) path[b].append(a) direction=[i for i in range(n)] fin=[False for i in range(n)] fin[0]=True i=0 queue=[0] while i<n: i+=1 queue2=queue.copy() queue.clear() if len(...
[["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22]]
5
228
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define FOR(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--) const ll INF = 1LL << 60; const int INF32 = 1 << 29; const ll MOD ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define FOR(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--) const ll INF = 1LL << 60; const int INF32 = 1 << 29; const ll MOD ...
[["-", 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
324
import sys from collections import deque sys.setrecursionlimit(10**6) readline = sys.stdin.readline def main(): N, M = map(int, readline().split()) graph = [[] for _ in range(M)] for _ in range(M): A, B = map(int, readline().split()) A -= 1; B -= 1 graph[A].append(B) graph[...
import sys from collections import deque sys.setrecursionlimit(10**6) readline = sys.stdin.readline def main(): N, M = map(int, readline().split()) graph = [[] for _ in range(N)] for _ in range(M): A, B = map(int, readline().split()) A -= 1; B -= 1 graph[A].append(B) graph[...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 0, 14, 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, ...
5
213
#include <bits/stdc++.h> using namespace std; int main() { // cin.tie(0); // ios::sync_with_stdio(false); int N, M; scanf("%d %d", &N, &M); vector<vector<pair<int, int>>> w(N + 1, vector<pair<int, int>>()); //(部屋,道番号) vector<pair<int, int>> result(N + 1, make_pair(N + 1...
#include <bits/stdc++.h> using namespace std; int main() { // cin.tie(0); // ios::sync_with_stdio(false); int N, M; scanf("%d %d", &N, &M); vector<vector<pair<int, int>>> w(N + 1, vector<pair<int, int>>()); //(部屋,道番号) vector<pair<int, int>> result(N + 1, make_pair(N + 1...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
374
# D - .. (Double Dots) from collections import deque N, M = map(int, input().split()) tree = [[] for _ in range(M)] for i in range(M): A, B = map(int, input().split()) A -= 1 B -= 1 tree[A].append(B) tree[B].append(A) ans_arr = [-1] * (N) q = deque() ans_arr[0] = 0 q.append(0) while len(q)>0: ...
# D - .. (Double Dots) from collections import deque N, M = map(int, input().split()) tree = [[] for _ in range(N)] for i in range(M): A, B = map(int, input().split()) A -= 1 B -= 1 tree[A].append(B) tree[B].append(A) ans_arr = [-1] * (N) q = deque() ans_arr[0] = 0 q.append(0) while len(q)>0: ...
[["-", 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 (ll i = 0; i < (ll)(n); i++) using namespace std; using ll = long long; int main() { ll N, M; cin >> N >> M; vector<vector<ll>> G(M, vector<ll>(0)); rep(i, M) { ll a, b; cin >> a >> b; --a; --b; G[a].push_back(b); G[b].push_back(a); } q...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; using ll = long long; int main() { ll N, M; cin >> N >> M; vector<vector<ll>> G(N, vector<ll>(0)); rep(i, M) { ll a, b; cin >> a >> b; --a; --b; G[a].push_back(b); G[b].push_back(a); } q...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22]]
1
314
#include <bits/stdc++.h> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(), (a).end() #define SZ(a) (int)(a).size() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define iFOR(i, a, b) for (int i = (a); i >= (b); --i) #define make_unique(a) ...
#include <bits/stdc++.h> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(), (a).end() #define SZ(a) (int)(a).size() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define iFOR(i, a, b) for (int i = (a); i >= (b); --i) #define make_unique(a) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
333
# abc168 D n, m = gets.split.map(&:to_i) ab = m.times.map { gets.split.map(&:to_i).map{|x|x-1} } nodes = Array.new(n){ [] } ab.each do |(a,b)| nodes[a] << b nodes[b] << a end lens = Array.new(n, 0) # pp nodes sirube = Array.new(n, nil) stack = [ 0 ] # index, len until stack.empty? s = stack.pop nodes[s...
# abc168 D n, m = gets.split.map(&:to_i) ab = m.times.map { gets.split.map(&:to_i).map{|x|x-1} } nodes = Array.new(n){ [] } ab.each do |(a,b)| nodes[a] << b nodes[b] << a end lens = Array.new(n, 0) # pp nodes sirube = Array.new(n, nil) stack = [ 0 ] # index, len until stack.empty? s = stack.shift nodes...
[["-", 0, 750, 8, 170, 0, 662, 12, 652, 735, 22], ["+", 0, 750, 8, 170, 0, 662, 12, 652, 735, 22]]
4
208
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC push_options #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include <bits/stdc++.h> #include <immintrin.h> #include <xmmintrin.h> using namespace ::std; __attribute__((constructor)) void init() { cin.tie(0); ios::sync...
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC push_options #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include <bits/stdc++.h> #include <immintrin.h> #include <xmmintrin.h> using namespace ::std; __attribute__((constructor)) void init() { cin.tie(0); ios::sync...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
1,874
//----AUTHOR:kkdrummer----/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; // typedef unordered_set<ll> usll; // typedef unordered_multiset<ll> umsll; typedef multiset<ll> msll; typedef set<ll> sl...
//----AUTHOR:kkdrummer----/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; // typedef unordered_set<ll> usll; // typedef unordered_multiset<ll> umsll; typedef multiset<ll> msll; typedef set<ll> sl...
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 44], ["+", 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
993
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back vector<int> adj[100001]; int visited[100001]; void dfs(int u) { // cout<<u<<" "; visited[u] = 1; for (auto i : adj[u]) if (visited[i] == 0) dfs(i); } int main() { int n, m; cin >> n >> m; int i, j, u, v; ...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back vector<int> adj[100001]; int visited[100001]; void dfs(int u) { // cout<<u<<" "; visited[u] = 1; for (auto i : adj[u]) if (visited[i] == 0) dfs(i); } int main() { int n, m; cin >> n >> m; int i, j, u, v; ...
[["-", 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
331
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <utility> #inc...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <utility> #inc...
[["-", 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
657
from collections import defaultdict, deque N, M = map(int, input().split()) X = defaultdict(list) for i in range(M): Ai, Bi = map(lambda s: int(s) - 1, input().split()) X[Ai].append(Bi) X[Bi].append(Ai) V = [False] * N P = [0] * N A = [0] * N Q = deque([0]) V[0] = True while len(Q) > 0: r = Q.popleft(...
from collections import defaultdict, deque N, M = map(int, input().split()) X = defaultdict(list) for i in range(M): Ai, Bi = map(lambda s: int(s) - 1, input().split()) X[Ai].append(Bi) X[Bi].append(Ai) V = [False] * N P = [0] * N A = [0] * N Q = deque([0]) V[0] = True while len(Q) > 0: r = Q.popleft(...
[["+", 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
// In the name of god #include <bits/stdc++.h> #pragma GCC optimze("02") using namespace std; using ll = long long; const ll maxn = 2e5 + 5, inf = 1e18 + 18; ll n, m, x, y, par[maxn]; bool mark[maxn], b; vector<ll> adj[maxn]; vector<ll> e[maxn]; void bfs(int u) { for (int i : e[u]) { for (int a : adj[i]) { ...
// In the name of god #include <bits/stdc++.h> #pragma GCC optimze("02") using namespace std; using ll = long long; const ll maxn = 2e5 + 5, inf = 1e18 + 18; ll n, m, x, y, par[maxn]; bool mark[maxn], b; vector<ll> adj[maxn]; vector<ll> e[maxn]; void bfs(int u) { for (int i : e[u]) { for (int a : adj[i]) { ...
[["-", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
330
#include <bits/stdc++.h> #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ll long long #define ull unsigned long long #define FI(i, a, n) for (int i = a; i <= n; i++) #define RFI(i, ...
#include <bits/stdc++.h> #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ll long long #define ull unsigned long long #define FI(i, a, n) for (int i = a; i <= n; i++) #define RFI(i, ...
[["-", 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
371
#include <bits/stdc++.h> using namespace std; int main(int argc, const char *argv[]) { int n, m; cin >> n >> m; vector<vector<int>> g(m); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; a--, b--; g[a].push_back(b); g[b].push_back(a); } vector<int> ans(n, -1); queue<int> q; ...
#include <bits/stdc++.h> using namespace std; int main(int argc, const char *argv[]) { int n, m; cin >> n >> m; vector<vector<int>> g(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; a--, b--; g[a].push_back(b); g[b].push_back(a); } vector<int> ans(n, -1); queue<int> q; ...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
267
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repo(i, n) for (int i = 1; i < (int)(n); i++) #define pb push_back #define mp make_pair #define np next_permutation #define lb lower_bound #define ub upper_bound #define...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repo(i, n) for (int i = 1; i < (int)(n); i++) #define pb push_back #define mp make_pair #define np next_permutation #define lb lower_bound #define ub upper_bound #define...
[["-", 0, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 0, 9, 0, 1, 0, 2, 63, 118, 119, 120]]
1
479
from collections import deque n, m = [int(x) for x in input().strip().split()] graph = {} for i in range(m): u, v = [int(x) for x in input().strip().split()] if u not in graph: graph[u] = [] if v not in graph: graph[v] = [] graph[u].append(v) graph[v].append(u) dp = [None for i in...
from collections import deque n, m = [int(x) for x in input().strip().split()] graph = {} for i in range(m): u, v = [int(x) for x in input().strip().split()] if u not in graph: graph[u] = [] if v not in graph: graph[v] = [] graph[u].append(v) graph[v].append(u) dp = [None for i in...
[["-", 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
261
# -*- coding: utf-8 -*- import sys import math import os import itertools import string import heapq import _collections from collections import Counter from collections import defaultdict from functools import lru_cache import bisect import re import queue from decimal import * class Scanner(): @staticmethod ...
# -*- coding: utf-8 -*- import sys import math import os import itertools import string import heapq import _collections from collections import Counter from collections import defaultdict from functools import lru_cache import bisect import re import queue from decimal import * class Scanner(): @staticmethod ...
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
687
def mp(): return map(int, input().split()) def lmp(): return list(map(int, input().split())) from collections import deque n,m = mp() path = [] for i in range(n+1): path.append([]) for i in range(m): a,b = mp() path[a].append(b) path[b].append(a) ans = [0]*(n+1) q = deque([1]) used = set() used.add(1...
def mp(): return map(int, input().split()) def lmp(): return list(map(int, input().split())) from collections import deque n,m = mp() path = [] for i in range(n+1): path.append([]) for i in range(m): a,b = mp() path[a].append(b) path[b].append(a) ans = [0]*(n+1) q = deque([1]) used = set() used.add(1...
[["-", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 0, 73], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612]]
5
206
#include <bits/stdc++.h> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, n, m) for (int i = m; i < (n); ++i) #define repl(i, n) for (long long i = 0; i < (n); ++i) #d...
#include <bits/stdc++.h> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, n, m) for (int i = m; i < (n); ++i) #define repl(i, n) for (long long i = 0; i < (n); ++i) #d...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
555
#include <bits/stdc++.h> using namespace std; using ll = long long int; using vi = vector<int>; #define f(n) for (int i = 0; i < n; i++) #define fj(n) for (int j = 0; j < n; j++) #define fk(n) for (int k = 0; k < n; k++) #define ci(n) cin >> n; #define ic(n) ...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using vi = vector<int>; #define f(n) for (int i = 0; i < n; i++) #define fj(n) for (int j = 0; j < n; j++) #define fk(n) for (int k = 0; k < n; k++) #define ci(n) cin >> n; #define ic(n) ...
[["-", 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], ["-", 0, 7, 8, 1, 0, 16, 12, 103, 0, 125], ["+", 0, 7, 8, 1, 0, 16, 12, 103, 0, 44]]
1
403
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define M...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define M...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
479