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 |
|---|---|---|---|---|
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
x,parent = tod... | N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
x,parent = deq... | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 230 |
#include "bits/stdc++.h"
#define REP(i, num) for (ll i = 0; i < (num); ++i)
#define LOOP(i) while (i--)
#define ALL(c) c.begin(), c.end()
#define PRINTALL(c) \
for (auto pitr = c.begin(); pitr != c.end(); ++pitr) { \
cout << *pitr; ... | #include "bits/stdc++.h"
#define REP(i, num) for (ll i = 0; i < (num); ++i)
#define LOOP(i) while (i--)
#define ALL(c) c.begin(), c.end()
#define PRINTALL(c) \
for (auto pitr = c.begin(); pitr != c.end(); ++pitr) { \
cout << *pitr; ... | [["-", 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 | 686 |
#include <bits/stdc++.h>
using namespace std;
#define pan(i, n) for (int i = 0; i < n; i++)
#define pans(i, n, a) for (int i = a; i < n; i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF INT_MAX
#define PI 3.141592653
#define inf 2000007
#define pll pair<ll, ll>... | #include <bits/stdc++.h>
using namespace std;
#define pan(i, n) for (int i = 0; i < n; i++)
#define pans(i, n, a) for (int i = a; i < n; i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF INT_MAX
#define PI 3.141592653
#define inf 2000007
#define pll pair<ll, ll>... | [["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]] | 1 | 385 |
from math import floor,ceil,sqrt
import fractions
import itertools
from collections import deque
import heapq
N,M=map(int,input().split())
tree=[[] for _ in range(N)]
for i in range(M):
a,b=map(int,input().split())
tree[a-1].append(b-1)
tree[b-1].append(a-1)
prev=[-1]*N
d=[float("inf")]
prev[0]=0
d=deque()
... | from math import floor,ceil,sqrt
import fractions
import itertools
from collections import deque
import heapq
N,M=map(int,input().split())
tree=[[] for _ in range(N)]
for i in range(M):
a,b=map(int,input().split())
tree[a-1].append(b-1)
tree[b-1].append(a-1)
prev=[-1]*N
d=[float("inf")]
prev[0]=0
d=deque()
... | [["+", 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 | 195 |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef vector<int> Vl;
typedef vector<vector<int>> Vv;
typedef pair<int, int> pii;
typedef vector<pii> Vll;
typedef vector<pair<int, pair<int, int>>> Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x, y) memset(x, y, sizeof(x)... | #include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef vector<int> Vl;
typedef vector<vector<int>> Vv;
typedef pair<int, int> pii;
typedef vector<pii> Vll;
typedef vector<pair<int, pair<int, int>>> Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x, y) memset(x, y, sizeof(x)... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 474 |
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL << 60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(... | #include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL << 60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(... | [["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 398 |
from collections import deque
n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
a,b = a-1,b-1
map_li[a].append(b)
map_li[b].append(a)
ans_li = [-1]*n
queue=deque([0])
visited = [False]*n
while queue:
x = queue.pop()
for g in map_li... | from collections import deque
n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
a,b = a-1,b-1
map_li[a].append(b)
map_li[b].append(a)
ans_li = [-1]*n
queue=deque([0])
visited = [False]*n
while queue:
x = queue.popleft()
for g in ma... | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]] | 5 | 201 |
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
int n, m;
vector<int> g[125252];
int dist[125252], bef[125252];
int main() {
scanf("%d%d", &n, &m);
REP(i, m) {
int u, v;
scanf("%d%d", &u, &v);
--u;
--v;
g[u].push_back(v);
g[v].push_back(u);
}
q... | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
int n, m;
vector<int> g[125252];
int dist[125252], bef[125252];
int main() {
scanf("%d%d", &n, &m);
REP(i, m) {
int u, v;
scanf("%d%d", &u, &v);
--u;
--v;
g[u].push_back(v);
g[v].push_back(u);
}
q... | [["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 263 |
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define int long long
#define f(i, l, n) for (int i = l; i < n; i++)
#define E "\n"
#define pi 3.141592653589793
int solve() {
int n, m;
cin >> n >> m;
vector<int> v[n + 1];
f(i, 0, m) {
int a, b;
cin >> a >>... | #include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define int long long
#define f(i, l, n) for (int i = l; i < n; i++)
#define E "\n"
#define pi 3.141592653589793
int solve() {
int n, m;
cin >> n >> m;
vector<int> v[n + 1];
f(i, 0, m) {
int a, b;
cin >> a >>... | [["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 294 |
from collections import deque
n, m = map(int, input().split())
route =[[] for i in range(m+1)]
for i in range(m):
a, b = map(int, input().split())
route[a].append(b)
route[b].append(a)
visited = [0 for i in range(n+1)]
visited[1] = 1
ans = [0 for i in range(n+1)]
D = deque()
D.append(1)
while D:
visit =... | from collections import deque
n, m = map(int, input().split())
route =[[] for i in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
route[a].append(b)
route[b].append(a)
visited = [0 for i in range(n+1)]
visited[1] = 1
ans = [0 for i in range(n+1)]
D = deque()
D.append(1)
while D:
visit =... | [["-", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 191 |
#include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define exrep(i, a, b) for (ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x =... | #include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define exrep(i, a, b) for (ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x =... | [["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22]] | 1 | 568 |
from collections import deque
N, M = map(int, input().split())
nei_L = [[] for _ in range(M)]
for i in range(M):
a, b = map(int, input().split())
nei_L[a - 1].append(b - 1)
nei_L[b - 1].append(a - 1)
ans = [-1] * N
queue = deque()
def bfs():
queue.append(0)
while len(queue) > 0:
now = q... | from collections import deque
N, M = map(int, input().split())
nei_L = [[] for _ in range(N)]
for i in range(M):
a, b = map(int, input().split())
nei_L[a - 1].append(b - 1)
nei_L[b - 1].append(a - 1)
ans = [-1] * N
queue = deque()
def bfs():
queue.append(0)
while queue:
now = queue.popl... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 52, 15, 666, 0, 652, 63, 22], ["-", 0, 52, 15, 666, 0, 652, 3, 4, 0, 24], ["-", 0, 52, 15, 666, 0, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 52, 15, 666, 667, 47], ["-", 0, 14, 8, 196, 0, 52, 15, 666, 0, 612]] | 5 | 197 |
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
int n, m;
vector<int> a[100001];
int d[100001... | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
int n, m;
vector<int> a[100001];
int d[100001... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 303 |
#include <bits/stdc++.h>
using namespace std;
int inf = 10000000;
typedef pair<int, int> P;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> to(n);
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
to[a].push_back(b);
to[b].push_back(a);
}
vector<int> paren... | #include <bits/stdc++.h>
using namespace std;
int inf = 10000000;
typedef pair<int, int> P;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> to(n);
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
to[a].push_back(b);
to[b].push_back(a);
}
vector<int> paren... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 293 |
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int n = sc.n... | import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int n = sc.n... | [["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]] | 3 | 372 |
n, m = map(int, input().split())
G = [[] for _ in range(m)]
for _ in range(m):
u, v = map(int, input().split())
u -= 1
v -= 1
G[u].append(v)
G[v].append(u)
ans = [-1] * n
# ans[0] = 'Yes'
from collections import deque
q = deque([0])
while q:
_q = q.popleft()
for x in G[_q]:
if a... | n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
u -= 1
v -= 1
G[u].append(v)
G[v].append(u)
ans = [-1] * n
from collections import deque
q = deque([0])
while q:
_q = q.popleft()
for x in G[_q]:
if ans[x] == -1:
... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]] | 5 | 170 |
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
int n, m, a, b;
cin >> n >> m;
vector<vector<int>> G(m + 1);
for (int i = 0; i < m; i++) {
cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
vector<int> ans(n + 1, -1);
queue<int> q;
q.push(1);
... | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
int n, m, a, b;
cin >> n >> m;
vector<vector<int>> G(n + 1);
for (int i = 0; i < m; i++) {
cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
vector<int> ans(n + 1, -1);
queue<int> q;
q.push(1);
... | [["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22]] | 1 | 220 |
import java.io.*;
import java.util.*;
public class Main {
static StringTokenizer st;
static BufferedReader br;
static PrintWriter out;
static int parent[];
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
int N = nextInt();
... | import java.io.*;
import java.util.*;
public class Main {
static StringTokenizer st;
static BufferedReader br;
static PrintWriter out;
static int parent[];
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
int N = nextInt();
... | [["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]] | 3 | 516 |
INF = 2 ** 62
n, m = gets.strip.split.map(&:to_i)
l = Array.new(n){[]}
ab = []
m.times do |i|
a, b = gets.strip.split.map(&:to_i)
ab.append [a, b]
l[a-1].append b-1
l[b-1].append a-1
end
ans = Array.new(n){[INF,0]} # distance, prev
q = [[0,0]] # node, distance
while q.size != 0
a... | INF = 2 ** 62
n, m = gets.strip.split.map(&:to_i)
l = Array.new(n){[]}
ab = []
m.times do |i|
a, b = gets.strip.split.map(&:to_i)
ab.append [a, b]
l[a-1].append b-1
l[b-1].append a-1
end
ans = Array.new(n){[INF,0]} # distance, prev
q = [[0,0]] # node, distance
while q.size != 0
a = ... | [["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]] | 4 | 205 |
from collections import deque
n, m = map(int, input().split())
route = [[] for i in range(m)]
for i in range(m):
a, b = map(int, input().split())
route[a-1].append(b - 1)
route[b-1].append(a - 1)
next_queue = deque()
sign = [-1] * n
sign[0] = 999
next_queue.append(0)
while next_queue:
current_number... | from collections import deque
n, m = map(int, input().split())
route = [[] for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
route[a-1].append(b - 1)
route[b-1].append(a - 1)
next_queue = deque()
sign = [-1] * n
sign[0] = 999
next_queue.append(0)
while next_queue:
current_number... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]] | 5 | 172 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
vector<int> dist;
vector<int> pre;
queue<int> que;
bool can = false;
void bfs(vector<vector<int>> &g) {
while (!que.empty()) {
int v = que.front();
que.pop();
for (auto nv : g[v]) {
if (dist[nv] != 0)
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
vector<int> dist;
vector<int> pre;
queue<int> que;
bool can = false;
void bfs(vector<vector<int>> &g) {
while (!que.empty()) {
int v = que.front();
que.pop();
for (auto nv : g[v]) {
if (dist[nv] != 0)
... | [["-", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]] | 1 | 294 |
def resolve():
n, m = map(int, input().split())
ab = [list(map(int, input().split()))for i in range(m)]
ans = [0] * n
edge = [[]for _ in range(n)]
for a, b in ab:
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
visited = {0}
stack = [0]
for i in stack:
for j i... | def resolve():
n, m = map(int, input().split())
ab = [list(map(int, input().split()))for i in range(m)]
ans = [0] * n
edge = [[]for _ in range(n)]
for a, b in ab:
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
visited = {0}
stack = [0]
for i in stack:
for j i... | [["+", 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, 25]] | 5 | 175 |
from collections import deque
N,M = (int(x) for x in input().split())
connected = [[] for _ in range(N+1)]
searched = [0] * (N+1)
signs = [0] * (N+1)
for i in range(M):
A,B = (int(x) for x in input().split())
connected[A].append(B)
connected[B].append(A)
d = deque()
for edge in connected[1]:
d.append(... | from collections import deque
N,M = (int(x) for x in input().split())
connected = [[] for _ in range(N+1)]
searched = [0] * (N+1)
signs = [0] * (N+1)
for i in range(M):
A,B = (int(x) for x in input().split())
connected[A].append(B)
connected[B].append(A)
d = deque()
for edge in connected[1]:
d.append(... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 0, 656, 0, 1, 0, 662, 31, 206, 0, 70]] | 5 | 207 |
N, M = map(int, input().split())
lists = [False for i in range(N)]
lists[0] = True
a = N - 1
dicts = {i:[] for i in range(N)}
d = deque([0])
for i in range(M):
tmpa, tmpb = map(lambda x: int(x) - 1, input().split())
dicts[tmpa] += [tmpb]
dicts[tmpb] += [tmpa]
print('Yes')
while a > 0:
tmp = d.poplef... | from collections import deque
N, M = map(int, input().split())
lists = [False for i in range(N)]
lists[0] = True
a = N - 1
dicts = {i:[] for i in range(N)}
d = deque([0])
for i in range(M):
tmpa, tmpb = map(lambda x: int(x) - 1, input().split())
dicts[tmpa] += [tmpb]
dicts[tmpb] += [tmpa]
print('Yes')
w... | [["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]] | 5 | 201 |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, a, b) for (ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#defin... | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, a, b) for (ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#defin... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 485 |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, long long> P;
int main() {
long long N, M;
cin >> N >> M;
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> used(N, -1);
vector<long ... | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, long long> P;
int main() {
long long N, M;
cin >> N >> M;
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> used(N, -1);
vector<long ... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 311 |
from queue import Queue
n,m = map(int,input().split())
grafo = [[] for i in range(n)]
for x in range(m):
a,b = map(int,input().split())
grafo[a-1].append(b)
grafo[b-1].append(a)
placas = [0] * (n)
def bfs(a):
q = Queue(maxsize = n)
placas[1] = 1
q.put(a)
while not q.empty():
po... | from queue import Queue
n,m = map(int,input().split())
grafo = [[] for i in range(n)]
for x in range(m):
a,b = map(int,input().split())
grafo[a-1].append(b)
grafo[b-1].append(a)
placas = [0] * (n)
def bfs(a):
q = Queue(maxsize = n)
placas[0] = 1
q.put(a)
while not q.empty():
po... | [["-", 8, 196, 0, 1, 0, 662, 31, 206, 206, 612], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 612]] | 5 | 204 |
#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>;
const int INF = 1001001001;
vector<int> to[100005]; //グラフ
int main() {
int n, m;
cin >> n >> m;
rep(i, m) {
int a, b;
cin >> a >> b;
--a;
--b;
to[a].push... | #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>;
const int INF = 1001001001;
vector<int> to[100005]; //グラフ
int main() {
int n, m;
cin >> n >> m;
rep(i, m) {
int a, b;
cin >> a >> b;
--a;
--b;
to[a].push... | [["+", 8, 9, 0, 52, 15, 339, 51, 91, 17, 111]] | 1 | 275 |
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"strconv"
)
var mat = make(map[int][]int)
func main() {
n, m := readInt(), readInt()
for i := 0; i < m; i++ {
a, b := readInt(), readInt()
if _, ok := mat[a]; !ok {
mat[a] = make([]int, 0)
}
mat[a] = append(mat[a], b)
if _, ok := mat[b]; !ok {... | package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"strconv"
)
var mat = make(map[int][]int)
func main() {
n, m := readInt(), readInt()
for i := 0; i < m; i++ {
a, b := readInt(), readInt()
if _, ok := mat[a]; !ok {
mat[a] = make([]int, 0)
}
mat[a] = append(mat[a], b)
if _, ok := mat[b]; !ok {... | [["-", 8, 196, 0, 1, 0, 2, 63, 438, 439, 22], ["-", 8, 196, 0, 1, 0, 2, 63, 438, 0, 131], ["-", 8, 196, 0, 1, 0, 2, 63, 438, 119, 120], ["-", 8, 196, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 435, 8, 196, 0, 7, 8, 196, 0, 165]] | 7 | 935 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> edge[n], ans(n, -1);
while (m--) {
int u, v;
cin >> u >> v;
u--;
v--;
edge[u].push_back(v);
edge[v].push_back(u);
}
queue<int> que;
que.push(0);
while (que.size()) {
int p = que.f... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> edge[n], ans(n, -1);
while (m--) {
int u, v;
cin >> u >> v;
u--;
v--;
edge[u].push_back(v);
edge[v].push_back(u);
}
queue<int> que;
que.push(0);
while (que.size()) {
int p = que.f... | [["+", 8, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 8, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 187 |
n,m=list(map(int, input().split()))
root = [[] for _ in range(n)]
answer=[0]*n
answer[0]=1
for i in range(m):
c=list(map(int, input().split()))
root[c[1]-1].append(c[0]-1)
root[c[0]-1].append(c[1]-1)
count=1#最初から1の部屋はOKにしとく
queue=[0]
#print(root)
newqueue=[]
while(count<n and len(queue)!=0):
for j in qu... | n,m=list(map(int, input().split()))
root = [[] for _ in range(n)]
answer=[-1]*n
answer[0]=1
for i in range(m):
c=list(map(int, input().split()))
root[c[1]-1].append(c[0]-1)
root[c[0]-1].append(c[1]-1)
count=1#最初から1の部屋はOKにしとく
queue=[0]
#print(root)
newqueue=[]
while(count<n and len(queue)!=0):
for j in q... | [["-", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612], ["+", 0, 662, 12, 657, 31, 634, 0, 664, 17, 33], ["+", 0, 662, 12, 657, 31, 634, 0, 664, 28, 612], ["-", 8, 196, 0, 57, 15, 23, 0, 666, 0, 612], ["+", 0, 57, 15, 23, 0, 666, 0, 664, 17, 33], ["+", 0, 57, 15, 23, 0, 666, 0, 664, 28, 612]] | 5 | 224 |
from collections import deque
n,m = map(int,input().split())
path = []
net = [[] for _ in range(n+1)]
for _ in range(m):
a,b = map(int,input().split())
net[a].append(b)
net[b].append(a)
a = [-1] * (n+1)
d = deque()
d.append(1)
while d:
u = d.popleft()
for child in net[u]:
if a[child] != -... | from collections import deque
n,m = map(int,input().split())
path = []
net = [[] for _ in range(n+1)]
for _ in range(m):
a,b = map(int,input().split())
net[a].append(b)
net[b].append(a)
a = [-1] * (n+1)
d = deque()
d.append(1)
while d:
u = d.popleft()
for child in net[u]:
if a[child] != -... | [["-", 0, 1, 0, 662, 12, 206, 206, 663, 0, 612], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 612]] | 5 | 186 |
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(M)]
for i in range(M):
A, B = map(int, input().split())
G[A-1].append(B-1)
G[B-1].append(A-1)
seen = [0 for _ in range(N)]
seen[0] = 1
shirube = [-1 for _ in range(N-1)]
stack = deque([0])
while stack:
now = stack.popleft()... | from collections import deque
N, M = map(int, input().split())
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)
seen = [0 for _ in range(N)]
seen[0] = 1
shirube = [-1 for _ in range(N-1)]
stack = deque([0])
while stack:
now = stack.popleft()... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]] | 5 | 220 |
import sys,queue,math,copy,itertools,bisect,collections
from heapq import *
def main():
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
SI = lambda : sys.stdin.readline().rstrip()
... | import sys,queue,math,copy,itertools,bisect,collections
from heapq import *
def main():
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
SI = lambda : sys.stdin.readline().rstrip()
... | [["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 70], ["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 73], ["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ... | 5 | 299 |
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
signed main() {
int n, m;
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].pb(b);
adj[b].pb(a);
}
vector<int> out(n);
vector<i... | #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
signed main() {
int n, m;
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].pb(b);
adj[b].pb(a);
}
vector<int> out(n);
vector<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 | 247 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vector<ll>> vv;
typedef vector<vector<vect... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vector<ll>> vv;
typedef vector<vector<vect... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 477 |
from typing import List
N, M = map(int, input().split())
graph:List[List[int]] = [[] for _ in range(N)]
for _ in range(N):
a,b = map(lambda x : int(x) -1 , input().split())
graph[a].append(b)
graph[b].append(a)
prev = [-1]*N
prev[0] = 0
import queue
qu = queue.Queue()
qu.put(0)
while not qu.empty():
top... | from typing import List
N, M = map(int, input().split())
graph:List[List[int]] = [[] for _ in range(N)]
for _ in range(M):
a,b = map(lambda x : int(x) -1 , input().split())
graph[a].append(b)
graph[b].append(a)
prev = [-1]*N
prev[0] = 0
import queue
qu = queue.Queue()
qu.put(0)
while not qu.empty():
top... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 223 |
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
N, M = map(int, input().split())
graph = [[] for _ in range(M)]
for _ in range(M):
A, B = map(int, input().split())
graph[A-1].append(B-1)
g... | import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
A, B = map(int, input().split())
# print(A, B)
graph[A-1]... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]] | 5 | 274 |
// Created by arvybhatt
#include <bits/stdc++.h>
#define fast \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define F f... |
// Created by arvybhatt
#include <bits/stdc++.h>
#define fast \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define F f... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 460 |
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
int main() {
int N, M;
cin >> N >> M;
Graph G... | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
int main() {
int N, M;
cin >> N >> M;
Graph G... | [["-", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]] | 1 | 276 |
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<int> ans(100005, -1);
const int INF = 10e9 + 10;
vector<int> dist(100005, INF);
void bfs(int s) {
queue<int> q;
q.push(s);
dist[s] = 0;
while (!q.empty()) {
int node = q.front();
q.pop();
for (auto i : adj[node]) {
i... | #include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<int> ans(100005, -1);
const int INF = 10e9 + 10;
vector<int> dist(100005, INF);
void bfs(int s) {
queue<int> q;
q.push(s);
dist[s] = 0;
while (!q.empty()) {
int node = q.front();
q.pop();
for (auto i : adj[node]) {
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 | 326 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt(); //9頂点
int M = sc.nextInt(); //13辺
List<Integer>[] edge = new ArrayList[N]; //9頂点
for (int i = 0; i < N; i++)
edge[i] = new ArrayList<>(); //リストにリストを入... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt(); //9頂点
int M = sc.nextInt(); //13辺
List<Integer>[] edge = new ArrayList[N]; //9頂点
for (int i = 0; i < N; i++)
edge[i] = new ArrayList<>(); //リストにリストを入... | [["-", 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 | 317 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e7;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> graph(m);
for (int i = 0; i < m; ++i) {
int a, b;
cin >> a >> b;
// 配列の位置と入力の数値を統一する
--a;
--b;
// aからb,
// b... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e7;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> graph(n);
for (int i = 0; i < m; ++i) {
int a, b;
cin >> a >> b;
// 配列の位置と入力の数値を統一する
--a;
--b;
// aからb,
// b... | [["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 308 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
/*struct cmp{ bool operator() ( const, const )const{}};
use as set<ll> ,cmp> a*/
int main() {
ios::sync_with_stdio(false... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
/*struct cmp{ bool operator() ( const, const )const{}};
use as set<ll> ,cmp> a*/
int main() {
ios::sync_with_stdio(false... | [["-", 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 | 417 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
/*struct cmp{ bool operator() ( const, const )const{}};
use as set<ll> ,cmp> a*/
int main() {
ios::sync_with_stdio(false... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
/*struct cmp{ bool operator() ( const, const )const{}};
use as set<ll> ,cmp> a*/
int main() {
ios::sync_with_stdio(false... | [["-", 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 | 335 |
from collections import deque
def main():
N, M, *AB = map(int, open(0).read().split())
C = {}
for i in range(M):
a = AB[2 * i + 0] - 1
b = AB[2 * i + 1] - 1
if a not in C:
C[a] = []
C[a].append(b)
if b not in C:
C[b] = []
C[b].append(a... | from collections import deque
def main():
N, M, *AB = map(int, open(0).read().split())
C = {}
for i in range(M):
a = AB[2 * i + 0] - 1
b = AB[2 * i + 1] - 1
if a not in C:
C[a] = []
C[a].append(b)
if b not in C:
C[b] = []
C[b].append(a... | [["-", 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 | 245 |
def main():
input1 = input()
input1 = input1.split()
N = int(input1[0])
M = int(input1[1])
aisle = {}
result = [0]*(N-1)
record = [1]
count = N-1
in1 = 0
in2 = 0
for i in range(M):
input2 = input()
input2 = input2.split()
in1 = int(input2[0])
... | def main():
input1 = input()
input1 = input1.split()
N = int(input1[0])
M = int(input1[1])
aisle = {}
result = [0]*(N-1)
record = [1]
count = N-1
in1 = 0
in2 = 0
for i in range(M):
input2 = input()
input2 = input2.split()
in1 = int(input2[0])
... | [["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 20], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612]] | 5 | 241 |
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
vector<vector<int>> E(N + 1, vector<int>());
for (int i = 0; i < M; i++) {
int Ai, Bi;
cin >> Ai >> Bi;
E[Ai].push_back(Bi);
E[Bi].push_back(Ai);
}
vector<int> res(N + 1,... | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
vector<vector<int>> E(N + 1, vector<int>());
for (int i = 0; i < M; i++) {
int Ai, Bi;
cin >> Ai >> Bi;
E[Ai].push_back(Bi);
E[Bi].push_back(Ai);
}
vector<int> res(N + 1,... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 301 |
#include "bits/stdc++.h"
using namespace std;
const long long inf = 1e9;
#define ll long long
#define fr(i, a, n) for (int i = a; i < n; i++)
#define rfr(i, n, a) for (int i = n; i >= a; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define endl "\n"
typedef vector... | #include "bits/stdc++.h"
using namespace std;
const long long inf = 1e9;
#define ll long long
#define fr(i, a, n) for (int i = a; i < n; i++)
#define rfr(i, n, a) for (int i = n; i >= a; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define endl "\n"
typedef vector... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 338 |
import bisect,collections,copy,heapq,itertools,math,numpy,string
#from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().r... | import bisect,collections,copy,heapq,itertools,math,numpy,string
#from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().r... | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 496 |
from collections import deque
n,m = map(int,input().split())
res = {}
for i in range(m):
a,b = map(int,input().split())
res.setdefault(a,[]).append(b)
res.setdefault(b,[]).append(a)
dist =[0] * (n+1)
sirusi = [0] * (n+1)
dist[1] = -1
que = deque([])
ique = deque([])
x = res.pop(1)
#print(x)
que.append(x... | from collections import deque
n,m = map(int,input().split())
res = {}
for i in range(m):
a,b = map(int,input().split())
res.setdefault(a,[]).append(b)
res.setdefault(b,[]).append(a)
dist =[0] * (n+1)
sirusi = [0] * (n+1)
dist[1] = -1
que = deque([])
ique = deque([])
x = res.pop(1)
#print(x)
que.append(x... | [["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]] | 5 | 281 |
from collections import deque
N, M = map(int, input().split())
ways = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
ways[a].append(b)
ways[b].append(a)
print(ways)
searched = [0 for i in range(N)]
searched[0] = 1
ans = [0 for i in range(N)]
d = deque([])
d.append(0)
... | from collections import deque
N, M = map(int, input().split())
ways = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
ways[a].append(b)
ways[b].append(a)
searched = [0 for i in range(N)]
searched[0] = 1
ans = [0 for i in range(N)]
d = deque([])
d.append(0)
while d:
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 | 193 |
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
List<List<Integer>> lists = new Arra... | import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
List<List<Integer>> lists = new Arra... | [["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491]] | 3 | 384 |
N, M = map(int, input().split())
graph = [[] for i 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)
from collections import deque
dist = [-1] * N
prev = [-1] * N
dist[0] = 0
queue = deque([0])
while queue:
tmp = queue.popleft()
... | N, M = map(int, input().split())
graph = [[] for i 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)
from collections import deque
dist = [-1] * N
prev = [-1] * N
dist[0] = 0
queue = deque([0])
while queue:
tmp = queue.popleft()
... | [["-", 36, 36, 0, 656, 0, 7, 12, 206, 51, 22], ["+", 36, 36, 0, 656, 0, 7, 12, 206, 51, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 183 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> path(M + 1);
for (int i = 1; i <= M; i++) {
int a, b;
cin >> a >> b;
path[a].push_back(b);
path[b].push_back(a);
}
vector<int> dist(N + 1, INT_MAX);
vector<int> prev(N + 1, INT_MAX);
... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> path(N + 1);
for (int i = 1; i <= M; i++) {
int a, b;
cin >> a >> b;
path[a].push_back(b);
path[b].push_back(a);
}
vector<int> dist(N + 1, INT_MAX);
vector<int> prev(N + 1, INT_MAX);
... | [["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22]] | 1 | 278 |
from collections import deque
n,m = map(int,input().split())
ab = [[] for _ in range(m)]
kr = [[] for _ in range(n)]
dist = [-1 for _ in range(n)]
dist[0] = 0
ans = [-1 for _ in range(n)]
qn = deque([1])
for i in range(m):
a,b = map(int,input().split())
a,b = min(a,b),max(a,b)
ab[i] = [a,b]
kr[a-1].a... | from collections import deque
n,m = map(int,input().split())
ab = [[] for _ in range(m)]
kr = [[] for _ in range(n)]
dist = [-1 for _ in range(n)]
dist[0] = 0
ans = [-1 for _ in range(n)]
qn = deque([1])
for i in range(m):
a,b = map(int,input().split())
a,b = min(a,b),max(a,b)
ab[i] = [a,b]
kr[a-1].a... | [["+", 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 | 252 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define drep(i, cc, n) for (int i = cc; i > n; --i)
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
t... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define drep(i, cc, n) for (int i = cc; i > n; --i)
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
t... | [["-", 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 | 435 |
N, M = map(int, input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
es[a-1].append(b-1)
es[b-1].append(a-1)
ans = [-1] * N
ans[0] = 0
from collections import deque
que = deque
que.insert(0)
while que:
s = que.popleft()
for v in es[s]... | N, M = map(int, input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
es[a-1].append(b-1)
es[b-1].append(a-1)
ans = [-1] * N
ans[0] = 0
from collections import deque
que = deque([])
que.append(0)
while que:
s = que.popleft()
for v in e... | [["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 634, 0, 70], ["+", 0, 662, 12, 652, 3, 4, 0, 634, 0, 73], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["-", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], [... | 5 | 177 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
... | [["-", 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 | 341 |
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using names... | // #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using names... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 290 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
int N, M;
int main(void) {
cin >> N >> M;
Graph G(N + 1);
for (int i = 1; i <= N; i++) {
int A, B;
cin >> A >> B;
G[A].push_back(B);
G[B].push_back(A);
}
vector<int> Arrow(N + 1, -1);
A... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
int N, M;
int main(void) {
cin >> N >> M;
Graph G(N + 1);
for (int i = 1; i <= M; i++) {
int A, B;
cin >> A >> B;
G[A].push_back(B);
G[B].push_back(A);
}
vector<int> Arrow(N + 1, -1);
A... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 298 |
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T> using V = vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
const ll inf = (1e18);
// const ll mod=998244353;
const ll mod = 1000000007;
ll GCD(ll a... | #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T> using V = vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
const ll inf = (1e18);
// const ll mod=998244353;
const ll mod = 1000000007;
ll GCD(ll a... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 490 |
from collections import deque, defaultdict
N, M = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(M):
a, b = map(lambda x: int(x)-1, input().split())
tree[a].append(b)
tree[b].append(a)
visited = [False]*N
q = deque([0])
visited[0] = True
ans = defaultdict(int)
while len(q):
v = ... | from collections import deque, defaultdict
N, M = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(M):
a, b = map(lambda x: int(x)-1, input().split())
tree[a].append(b)
tree[b].append(a)
visited = [False]*N
q = deque([0])
visited[0] = True
ans = defaultdict(int)
while len(q):
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 | 177 |
from collections import deque
n,m=map(int,input().split())
L=[[] for i in range(n)]
#print(L)
for i in range(m):
a,b=map(int,input().split())
L[a-1].append(b-1)
L[b-1].append(a-1)
#print(L)
d=[float('inf') for i in range(n)]
m=[0 for i in range(n)]
def bfs():
que=deque([])
que.append(0)
d[... | from collections import deque
n,m=map(int,input().split())
L=[[] for i in range(n)]
#print(L)
for i in range(m):
a,b=map(int,input().split())
L[a-1].append(b-1)
L[b-1].append(a-1)
#print(L)
d=[float('inf') for i in range(n)]
m=[0 for i in range(n)]
def bfs():
que=deque([])
que.append(0)
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 | 235 |
import collections
def main():
n, m = map(int, input().split())
g = [[] for i in range(m)]
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)
ans = solve(n, m, g)
if -1 in ans:
print('No')
else:
p... | import collections
def main():
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)
ans = solve(n, m, g)
if -1 in ans:
print('No')
else:
p... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]] | 5 | 256 |
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <climits>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include ... | #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <climits>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include ... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 586 |
from collections import defaultdict
import queue
N,M = map(int,input().split())
guide = {}
room = defaultdict(list)
for i in range(M):
a,b = map(int,input().split())
room[a].append(b)
room[b].append(a)
print(room)
q = queue.Queue()
for i in room[1]:
q.put(i)
guide[i] = 1
while not(q.empty()):... | from collections import defaultdict
import queue
N,M = map(int,input().split())
guide = {}
room = defaultdict(list)
for i in range(M):
a,b = map(int,input().split())
room[a].append(b)
room[b].append(a)
q = queue.Queue()
for i in room[1]:
q.put(i)
guide[i] = 1
while not(q.empty()):
x = q.g... | [["-", 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], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 12, 612]] | 5 | 191 |
from collections import deque
N,M=map(int,input().split())
tree=[[0] for _ in range(N)]
for _ in range(M):
A,B=map(int,input().split())
tree[A-1].append(B-1)
tree[B-1].append(A-1)
dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
v = que.popleft()
d = dist[v]
for w in tree[v]:
if... | from collections import deque
N,M=map(int,input().split())
tree=[[0] for _ in range(N)]
for _ in range(M):
A,B=map(int,input().split())
tree[A-1].append(B-1)
tree[B-1].append(A-1)
dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
v = que.popleft()
d = dist[v]
for w in tree[v]:
if... | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 206, 51, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 175 |
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#include <cmath>
// long long mod=180143987779;
// vector<long long > t(4*100001);
// long long gcd(long long a,long long b)
// {
// if(b>a)
// {
// return gcd(b,a);
// }
// if(b==0)
// {
// return a;
// }
// else
// {
// ... | #include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#include <cmath>
// long long mod=180143987779;
// vector<long long > t(4*100001);
// long long gcd(long long a,long long b)
// {
// if(b>a)
// {
// return gcd(b,a);
// }
// if(b==0)
// {
// return a;
// }
// else
// {
// ... | [["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]] | 1 | 539 |
from collections import deque
n, m = map(int, input().split())
G = [[] for _ in range(n+1)]
par = [0] * (n+1)
for _ in range(m):
x, y = map(int, input().split())
G[x].append(y)
G[y].append(x)
print(G)
visited = [0] + [1] + [0] * (n-1)
q = deque()
q.append(1)
while q:
now = q.popleft()
#print("now:... | from collections import deque
n, m = map(int, input().split())
G = [[] for _ in range(n+1)]
par = [0] * (n+1)
for _ in range(m):
x, y = map(int, input().split())
G[x].append(y)
G[y].append(x)
visited = [0] + [1] + [0] * (n-1)
q = deque()
q.append(1)
while q:
now = q.popleft()
#print("now:", now)
... | [["-", 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 | 200 |
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char *na, Arg1 &&arg1, Args &&...args) {
const char *... | #include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char *na, Arg1 &&arg1, Args &&...args) {
const char *... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 588 |
N, M = map(int, input().split())
A = []
B = []
pt = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
a -=1
b -=1
pt[a].append(b)
pt[b].append(a)
n=N
res_list = [-1] * N
def bfs(v):
d=[-1]*n
d[v]=0
q=[v]
c=1
while q:
q1=[]
for i in q:
for j ... | N, M = map(int, input().split())
A = []
B = []
pt = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
a -=1
b -=1
pt[a].append(b)
pt[b].append(a)
n=N
res_list = [-1] * N
def bfs(v):
d=[-1]*n
d[v]=0
q=[v]
c=1
while q:
q1=[]
for i in q:
for j ... | [["-", 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 | 237 |
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846264338327950L
int dist[100001];
bool visited[100001];
vector<int> adj[100001];
void bfs(int at) {
queue<int> q;
visited[at] = true;
q.push(at);
while (!q.empty()) {
int u = q.front();
q.pop();
for (auto to : adj[u... | #include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846264338327950L
int dist[100001];
bool visited[100001];
vector<int> adj[100001];
void bfs(int at) {
queue<int> q;
visited[at] = true;
q.push(at);
while (!q.empty()) {
int u = q.front();
q.pop();
for (auto to : adj[u... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 371 |
#include <bits/stdc++.h>
using namespace std;
const string YES = "Yes";
const string NO = "No";
void solve(long long N, long long M, std::vector<long long> A,
std::vector<long long> B) {
vector<vector<long long>> lis(N + 1);
vector<long long> path(N + 1, LLONG_MAX);
for (long long i = 0; i < N; i++) ... | #include <bits/stdc++.h>
using namespace std;
const string YES = "Yes";
const string NO = "No";
void solve(long long N, long long M, std::vector<long long> A,
std::vector<long long> B) {
vector<vector<long long>> lis(N + 1);
vector<long long> path(N + 1, LLONG_MAX);
for (long long i = 0; i < M; i++) ... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 421 |
import itertools
import math
import fractions
import functools
import copy
from collections import deque
n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for i in range(m):
a, b = map(int, input().split())
ab[a-1].append(b-1)
ab[b-1].append(a-1)
ans = [-1] * n
d = deque([0])
while d:
f = ... | import itertools
import math
import fractions
import functools
import copy
from collections import deque
n, m = map(int, input().split())
ab = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
ab[a-1].append(b-1)
ab[b-1].append(a-1)
ans = [-1] * n
d = deque([0])
while d:
f = ... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]] | 5 | 173 |
import itertools
import math
import fractions
import functools
import copy
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)
print(g)
a = [-1]*n
d = deque([0])
whi... | import itertools
import math
import fractions
import functools
import copy
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)
a = [-1]*n
d = deque([0])
while d:
... | [["-", 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 | 175 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llinf (1ll << 62)
#define BG(x) ((x).begin())
#define ED(x) ((x).end())
#define rBG(x) ((x).rbegin())
#define rED(x) ((x).rend())
#define mp(a, b) make_pair((a), (b))
ll t;
ll n, m;
vector<ll> edge[100005];
ll p[100005];
bitset<100005> visited... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llinf (1ll << 62)
#define BG(x) ((x).begin())
#define ED(x) ((x).end())
#define rBG(x) ((x).rbegin())
#define rED(x) ((x).rend())
#define mp(a, b) make_pair((a), (b))
ll t;
ll n, m;
vector<ll> edge[100005];
ll p[100005];
bitset<100005> visited... | [["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 313 |
import sys
import os
from collections import deque
def file_input():
f = open('ABC168/input.txt', 'r')
sys.stdin = f
def main():
if os.getenv("ENV")=='LOCAL':
file_input()
N,M=map(int, input().split())
r={}
for i in range(M):
A,B=map(int, input().split())
# print("A:"+... | import sys
import os
from collections import deque
def file_input():
f = open('ABC168/input.txt', 'r')
sys.stdin = f
def main():
if os.getenv("ENV")=='LOCAL':
file_input()
N,M=map(int, input().split())
r={}
for i in range(M):
A,B=map(int, input().split())
# print("A:"+... | [["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 259 |
def function():
N,M = map(int, input().split())
paths = []
for _m in range(M+1):
paths.append([])
for _m in range(M):
A,B = map(int, input().split())
paths[A].append(B)
paths[B].append(A)
dist = [-1]*(N+1)
dist[1] = 0
pre = [-1]*(N+1)
q = [1]... | def function():
N,M = map(int, input().split())
paths = []
for _ in range(N+1):
paths.append([])
for _m in range(M):
A,B = map(int, input().split())
paths[A].append(B)
paths[B].append(A)
dist = [-1]*(N+1)
dist[1] = 0
pre = [-1]*(N+1)
q = [1] # 1か... | [["-", 0, 656, 0, 14, 8, 196, 0, 7, 31, 22], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 214 |
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i < n; i++)
#define rf(i, n) for (int i = n - 1; i >= 0; i--)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x, y)... | #include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i < n; i++)
#define rf(i, n) for (int i = n - 1; i >= 0; i--)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x, y)... | [["-", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22]] | 1 | 503 |
from collections import deque
def main():
N,M = map(int, input().split())
r = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
r[a-1].append(b-1)
r[b-1].append(a-1)
print(r)
p=[-1]*N
q=deque([0])
while q:
i=q.popleft()
for j... | from collections import deque
def main():
N,M = map(int, input().split())
r = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
r[a-1].append(b-1)
r[b-1].append(a-1)
p=[-1]*N
q=deque([0])
while q:
i=q.popleft()
for j in r[i]:
... | [["-", 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 | 175 |
from collections import deque
n, m = map(int, input().split())
u = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
u[a].append(b)
u[b].append(a)
q = deque([0])
ans = [-1] * n
count = 0
while len(q):
p = q.popleft()
for x in u[p]:
if ans[x... | from collections import deque
n, m = map(int, input().split())
u = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
u[a].append(b)
u[b].append(a)
q = deque([0])
ans = [-1] * n
count = 0
while len(q):
p = q.popleft()
for x in u[p]:
if ans[x... | [["-", 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 | 171 |
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves =... | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves =... | [["-", 0, 1, 0, 16, 31, 16, 31, 2, 63, 22], ["+", 0, 1, 0, 16, 31, 16, 31, 2, 63, 22], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 13]] | 1 | 276 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int32_t main() {
int n, m;
cin >> n >> m;
vector<int> g[n + 1];
vector<int> ans(n + 1, 0);
for (int i = 0, u, v; i < m; i++) {
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
int cnt = 1;
queue<int> q;
q.push(1);
... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int32_t main() {
int n, m;
cin >> n >> m;
vector<int> g[n + 1];
vector<int> ans(n + 1, 0);
for (int i = 0, u, v; i < m; i++) {
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
int cnt = 1;
queue<int> q;
q.push(1);
... | [["-", 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 | 239 |
n,m=map(int,input().split())
d={}
for i in range(m):
x,y=map(int,input().split())
if x in d:
d[x].append(y)
else:
d[x]=[y]
if y in d:
d[y].append(x)
else:
d[y]=[x]
parent=[0]*(n+1)
bfs=[1]
visited=set([1])
while len(bfs)!=0:
x=bfs.pop(0)
visited.add(x)
for i in d[x]:
if i not in visited:
bfs.appen... | n,m=map(int,input().split())
d={}
for i in range(m):
x,y=map(int,input().split())
if x in d:
d[x].append(y)
else:
d[x]=[y]
if y in d:
d[y].append(x)
else:
d[y]=[x]
parent=[0]*(n+1)
bfs=[1]
visited=set([1])
while len(bfs)!=0:
x=bfs.pop(0)
visited.add(x)
for i in d[x]:
if i not in visited:
bfs.appen... | [["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]] | 5 | 211 |
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<int>;
int main() {
int N, M;
cin >> N >> M;
Graph G[M];
for (int i = 0; i < M; i++) {
int s, t;
cin >> s >> t;
G[s - 1].push_back(t - 1);
G[t - 1].push_back(s - 1);
}
vector<int> dist(N, -1);
int key[N];
queue<int> que;... | #include <bits/stdc++.h>
using namespace std;
using Graph = vector<int>;
int main() {
int N, M;
cin >> N >> M;
Graph G[N];
for (int i = 0; i < M; i++) {
int s, t;
cin >> s >> t;
G[s - 1].push_back(t - 1);
G[t - 1].push_back(s - 1);
}
vector<int> dist(N, -1);
int key[N];
queue<int> que;... | [["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22]] | 1 | 284 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> G[M];
for (int i = 0; i < M; i++) {
int s, t;
cin >> s >> t;
s--;
t--;
G[s].push_back(t);
G[t].push_back(s);
}
vector<int> ans(N, -1);
queue<int> que;
ans[0] = 0;
que.push(0);
w... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> G[N];
for (int i = 0; i < M; i++) {
int s, t;
cin >> s >> t;
s--;
t--;
G[s].push_back(t);
G[t].push_back(s);
}
vector<int> ans(N, -1);
queue<int> que;
ans[0] = 0;
que.push(0);
w... | [["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 338, 39, 40], ["+", 0, 52, 8, 9, 0, 338, 39, 361, 0, 190]] | 1 | 221 |
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, N) for (ll i = 0; i < (N); ++i)
int mai... | #include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, N) for (ll i = 0; i < (N); ++i)
int mai... | [["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 367 |
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
string explanation1 = "これは幅優先探索の問題!";
string explanation2 =
"参考URL:https://qiita.com/drken/items/996d80bcae64649a6580";
const int INF = 1001001001;
int main() {
int n, m;
cin >> n >> m;
//グラフ入力受け取り
Graph G(m);
for (int i =... | #include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
string explanation1 = "これは幅優先探索の問題!";
string explanation2 =
"参考URL:https://qiita.com/drken/items/996d80bcae64649a6580";
const int INF = 1001001001;
int main() {
int n, m;
cin >> n >> m;
//グラフ入力受け取り
Graph G(100005);
for (in... | [["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 337 |
N,M = map(int,input().split()) #n:頂点数 w:辺の数
way = [[] for i in range(M)]
depth = [float("inf") for i in range(N)]
visited = [False for i in range(N)]
que=[0]
for i in range(M):
x,y = map(int,input().split())
way[x-1].append(y-1)
way[y-1].append(x-1)
for i in que:
for j in way[i]:
if visited[j]:
... | N,M = map(int,input().split()) #n:頂点数 w:辺の数
way = [[] for i in range(N)]
depth = [float("inf") for i in range(N)]
visited = [False for i in range(N)]
que=[0]
for i in range(M):
x,y = map(int,input().split())
way[x-1].append(y-1)
way[y-1].append(x-1)
for i in que:
for j in way[i]:
if visited[j]:
... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]] | 5 | 185 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(), (x).end()
#define rp(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define irp(i, s, e) for (int i = (int)(s); i > (int)(e); --i)
// #define NMAX 1000000000
int N, M;
vvi ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(), (x).end()
#define rp(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define irp(i, s, e) for (int i = (int)(s); i > (int)(e); --i)
// #define NMAX 1000000000
int N, M;
vvi ... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 1 | 272 |
from collections import deque
n,m = list(map(int,input().split()))
e = [[] for _ in range(m+1)]
for i in range(m):
a,b = list(map(int,input().split()))
e[a].append(b)
e[b].append(a)
q = deque()
q.append(1)
t = [-1 for _ in range(n+1)]
while len(q):
node = q.popleft()
for i in range(len(e[node]))... | from collections import deque
n,m = list(map(int,input().split()))
e = [[] for _ in range(n+1)]
for i in range(m):
a,b = list(map(int,input().split()))
e[a].append(b)
e[b].append(a)
q = deque()
q.append(1)
t = [-1 for _ in range(n+1)]
while len(q):
node = q.popleft()
for i in range(len(e[node]))... | [["-", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 191 |
from collections import deque
n,m=map(int,input().split())
edges=[[] for _ in range(n)]#[[1番目の部屋からいける部屋],[2番目の部屋からいける部屋]...]
for _ in range(m):
a,b=map(int,input().split())
edges[a-1].append(b-1)
edges[b-1].append(a-1)
todo=deque([0,0])
seen=[-1]*n
seen[0]=0
while todo:
node,parent=todo.popleft()#現... | from collections import deque
n,m=map(int,input().split())
edges=[[] for _ in range(n)]#[[1番目の部屋からいける部屋],[2番目の部屋からいける部屋]...]
for _ in range(m):
a,b=map(int,input().split())
edges[a-1].append(b-1)
edges[b-1].append(a-1)
todo=deque([[0,0]])
seen=[-1]*n
seen[0]=0
while todo:
node,parent=todo.popleft()... | [["+", 12, 652, 3, 4, 0, 634, 0, 634, 0, 70], ["+", 12, 652, 3, 4, 0, 634, 0, 634, 0, 73]] | 5 | 176 |
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> to(n);
for ... | #include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> to(n);
for ... | [["-", 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 | 267 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef float fl;
typedef long long ll;
static const int INF = 1001001001;
int n;
static const int MAX = 100000;
vector<int> a[MAX];
int p[MAX];
void bfs(int s) {
queue<int> q;
int d[n];
rep(i, n) d[i] = INF;
d[s] = ... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef float fl;
typedef long long ll;
static const int INF = 1001001001;
int n;
static const int MAX = 100000;
vector<int> a[MAX];
int p[MAX];
void bfs(int s) {
queue<int> q;
int d[n];
rep(i, n) d[i] = INF;
d[s] = ... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 339 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> g[n];
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
vector<int> visit(n + 1);
vector<int> paraent(n + 1);
queue<int> q;
q.push(1);
visit[1]... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> g[n + 1];
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
vector<bool> visit(n + 1);
vector<int> paraent(n + 1);
queue<int> q;
q.push(1);
vis... | [["+", 8, 9, 0, 43, 49, 80, 81, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 220 |
#include <bits/stdc++.h>
using namespace std;
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define lli long... | #include <bits/stdc++.h>
using namespace std;
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define lli long... | [["-", 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 | 358 |
//....SARANSH GUPTA....\\
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p, n) for (int i = p; i < n; i++)
#define FIO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | //....SARANSH GUPTA....\\
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p, n) for (int i = p; i < n; i++)
#define FIO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | [["-", 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 | 356 |
import queue
N, M = map(int, input().split())
adj = [[] for i in range(N+1)]
parent = [-1] * (N+1)
for m in range(N):
a, b = map(int, input().split())
adj[a].append(b)
adj[b].append(a)
q = queue.Queue()
q.put((1,0))
while(not q.empty()):
x, p = q.get()
if parent[x] != -1:
continue
paren... | import queue
N,M = map(int,input().split())
adj = [[]for i in range(N+1)]
parent = [-1] * (N+1) # -1なら未訪問
for m in range(M):
a,b = map(int,input().split())
adj[a].append(b)
adj[b].append(a)
q = queue.Queue() # 自分の部屋番号、親の部屋番号
q.put((1,0)) # 部屋1の親は部屋0と考える
while(not q.empty()):
x, p = q.get()
if parent... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655]] | 5 | 185 |
n,m=map(int,input().split())
g=[[] for x in range(n)]
for c in range(M):
a,b= map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
ans_list=[-1]*n
queue=[0]
while queue:
qi=queue.pop(0)
for gi in g[qi]:
if ans_list[gi]==-1:
queue.append(gi)
ans_list[gi]=q... | n,m=map(int,input().split())
g=[[] for x in range(n)]
for c in range(m):
a,b= map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
ans_list=[-1]*n
queue=[0]
while queue:
qi=queue.pop(0)
for gi in g[qi]:
if ans_list[gi]==-1:
queue.append(gi)
ans_list[gi]=q... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 153 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.