message stringlengths 2 22.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 16 109k | cluster float64 1 1 | __index_level_0__ int64 32 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the e... | instruction | 0 | 25,189 | 1 | 50,378 |
Tags: data structures, dfs and similar, dsu, graphs, greedy
Correct Solution:
```
from sys import stdin,stdout
# Testing https://codeforces.com/contest/659/submission/54795830
n,m=stdin.readline().strip().split(' ')
n,m=int(n),int(m)
adj_li=[[] for i in range(n+1)]
for i in range(m):
u,v=stdin.readline().strip().spli... | output | 1 | 25,189 | 1 | 50,379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the e... | instruction | 0 | 25,190 | 1 | 50,380 |
Tags: data structures, dfs and similar, dsu, graphs, greedy
Correct Solution:
```
n,m=map(int,input().split())
g=[[] for i 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)
a=0
v=[-1]*n
def dfs(x):
global a
s=[x]
v[x]=-2
while s:
x=s.... | output | 1 | 25,190 | 1 | 50,381 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the e... | instruction | 0 | 25,191 | 1 | 50,382 |
Tags: data structures, dfs and similar, dsu, graphs, greedy
Correct Solution:
```
from sys import stdin,stdout
import os, io
# Testing https://codeforces.com/contest/659/submission/54795830
stdin = io.BytesIO(os.read(0, os.fstat(0).st_size))
n,m=stdin.readline().split()
n,m=int(n),int(m)
adj_li=[[] for i in range(n+1... | output | 1 | 25,191 | 1 | 50,383 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the e... | instruction | 0 | 25,192 | 1 | 50,384 |
Tags: data structures, dfs and similar, dsu, graphs, greedy
Correct Solution:
```
# this is a copy from http://codeforces.com/blog/entry/59832
n, m = map(int, input().split())
g = {v : [] for v in range(1, n + 1)}
for e in range(m):
u, v = map(int, input().split())
g[u].append(v)
g[v].append(u)
glob_vis = ... | output | 1 | 25,192 | 1 | 50,385 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the e... | instruction | 0 | 25,193 | 1 | 50,386 |
Tags: data structures, dfs and similar, dsu, graphs, greedy
Correct Solution:
```
import sys,threading
N=100020
v=[[] for i in range(N+3)]
vis=[False for i in range(N)]
tree=True
def dfs(node,par):
global vis,v,tree
vis[node]=True
# print(node,end = " ")
for i in v[node]:
if... | output | 1 | 25,193 | 1 | 50,387 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the e... | instruction | 0 | 25,194 | 1 | 50,388 |
Tags: data structures, dfs and similar, dsu, graphs, greedy
Correct Solution:
```
from sys import stdin,stdout
# Testing https://codeforces.com/contest/659/submission/54795830
n,m=stdin.readline().strip().split(' ')
n,m=int(n),int(m)
adj_li=[[] for i in range(n+1)]
for i in range(m):
u,v=stdin.readline().strip().spli... | output | 1 | 25,194 | 1 | 50,389 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the e... | instruction | 0 | 25,195 | 1 | 50,390 |
Tags: data structures, dfs and similar, dsu, graphs, greedy
Correct Solution:
```
n,m=map(int,input().split())
e=[[] for i in range(n+1)]
f=[0]*(n+1); ans=0
for i in range(m):
po,ki=map(int,input().split())
e[po].append(ki); e[ki].append(po)
for i in range(1,n+1):
if f[i]: continue
ch=[(i,0)]; f[i]=1; fl=1
wh... | output | 1 | 25,195 | 1 | 50,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,196 | 1 | 50,392 |
Yes | output | 1 | 25,196 | 1 | 50,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,197 | 1 | 50,394 |
Yes | output | 1 | 25,197 | 1 | 50,395 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,198 | 1 | 50,396 |
Yes | output | 1 | 25,198 | 1 | 50,397 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,199 | 1 | 50,398 |
Yes | output | 1 | 25,199 | 1 | 50,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,200 | 1 | 50,400 |
No | output | 1 | 25,200 | 1 | 50,401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,201 | 1 | 50,402 |
No | output | 1 | 25,201 | 1 | 50,403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,202 | 1 | 50,404 |
No | output | 1 | 25,202 | 1 | 50,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get f... | instruction | 0 | 25,203 | 1 | 50,406 |
No | output | 1 | 25,203 | 1 | 50,407 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Z... | instruction | 0 | 25,257 | 1 | 50,514 |
Tags: constructive algorithms, dfs and similar, dp, graphs, shortest paths, trees
Correct Solution:
```
from collections import deque
def bfs(graph, alphas):
"""Breadth first search on a graph!"""
ans = set()
n = len(graph)
q = deque([alpha for alpha in alphas])
used = [False]*n
for alpha in q:... | output | 1 | 25,257 | 1 | 50,515 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Z... | instruction | 0 | 25,258 | 1 | 50,516 |
Tags: constructive algorithms, dfs and similar, dp, graphs, shortest paths, trees
Correct Solution:
```
import math
import sys
input = sys.stdin.readline
inf = int(1e9)
n, m, d = map(int, input().split())
l = [0] * (n - 1)
r = [0] * (n - 1)
g = [[] for _ in range(n)]
station = [int(_) - 1 for _ in input().split()]
for... | output | 1 | 25,258 | 1 | 50,517 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Z... | instruction | 0 | 25,259 | 1 | 50,518 |
Tags: constructive algorithms, dfs and similar, dp, graphs, shortest paths, trees
Correct Solution:
```
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('ou... | output | 1 | 25,259 | 1 | 50,519 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always read... | instruction | 0 | 25,260 | 1 | 50,520 |
No | output | 1 | 25,260 | 1 | 50,521 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always read... | instruction | 0 | 25,261 | 1 | 50,522 |
No | output | 1 | 25,261 | 1 | 50,523 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always read... | instruction | 0 | 25,262 | 1 | 50,524 |
No | output | 1 | 25,262 | 1 | 50,525 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always read... | instruction | 0 | 25,263 | 1 | 50,526 |
No | output | 1 | 25,263 | 1 | 50,527 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,782 | 1 | 51,564 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from heapq import heappush,heappop
tupleMOD = 10 ** 10
INF = 10 ** 17
def minDist(a,b):
yDist = abs(a % tupleMOD - b % tupleMOD)
xDist = abs((a // tupleMOD) - (b // tupleMOD))... | output | 1 | 25,782 | 1 | 51,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,783 | 1 | 51,566 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
n, m = map(int, input().split())
sx, sy, fx, fy = map(int, input().split())
def get_dis(x, y, fx, fy):
return abs(fx - x) + abs(fy - y)
def ins_dis(x, y, fx, fy):
return min(abs(fx - x), abs(fy - y))
edge = [[] for i in range(m + 2)]
# ans = dis(sx... | output | 1 | 25,783 | 1 | 51,567 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,784 | 1 | 51,568 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode... | output | 1 | 25,784 | 1 | 51,569 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,785 | 1 | 51,570 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from heapq import heappush,heappop
tupleMOD = 10 ** 10
INF = 10 ** 13
def minDist(a,b):
yDist = abs(a % tupleMOD - b % tupleMOD)
xDist = abs((a // tupleMOD) - (b // tupleMOD))... | output | 1 | 25,785 | 1 | 51,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,786 | 1 | 51,572 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
import heapq
n, m = map(int, input().split())
sx, sy, fx, fy = map(int, input().split())
sub = [0]*(m+2)
sub[0] = (sx,sy)
dx = []
dy = []
for i in range(m):
x, y = map(int, input().split())
dx.append((x, i+1))
dy.append((y, i+1))
sub[i+1] = ... | output | 1 | 25,786 | 1 | 51,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,787 | 1 | 51,574 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
import sys, io, os
import math, random
import heapq as hq
from collections import defaultdict
# available on Google, not available on Codeforces
# import numpy as np
# import scipy
def console(*args):
# print on terminal in different color
print('... | output | 1 | 25,787 | 1 | 51,575 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,788 | 1 | 51,576 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
import heapq
def main():
n, m = map(int, input().split())
sx, sy, fx, fy = map(int, input().split())
sub = [0]*(m+2)
sub[0] = (sx,sy)
dx = []
dy = []
for i in range(m):
x, y = map(int, input().split())
dx.append... | output | 1 | 25,788 | 1 | 51,577 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Let's represent the city as an area of n Γ n squa... | instruction | 0 | 25,789 | 1 | 51,578 |
Tags: graphs, shortest paths, sortings
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode... | output | 1 | 25,789 | 1 | 51,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,790 | 1 | 51,580 |
Yes | output | 1 | 25,790 | 1 | 51,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,791 | 1 | 51,582 |
Yes | output | 1 | 25,791 | 1 | 51,583 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,792 | 1 | 51,584 |
Yes | output | 1 | 25,792 | 1 | 51,585 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,793 | 1 | 51,586 |
Yes | output | 1 | 25,793 | 1 | 51,587 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,794 | 1 | 51,588 |
No | output | 1 | 25,794 | 1 | 51,589 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,795 | 1 | 51,590 |
No | output | 1 | 25,795 | 1 | 51,591 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,796 | 1 | 51,592 |
No | output | 1 | 25,796 | 1 | 51,593 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.
Le... | instruction | 0 | 25,797 | 1 | 51,594 |
No | output | 1 | 25,797 | 1 | 51,595 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,011 | 1 | 52,022 |
Tags: flows, graphs, math
Correct Solution:
```
# coding:utf-8
"""
CF546E
"""
import sys
import copy
import os
# sys.stdin = open(os.path.join(os.path.dirname(__file__), 'in1'))
n, m = map(lambda x :int(x), input().strip().split())
a =[_ for _ in map(lambda x :int(x), input().strip().split())]
b = [_ for _ in map(l... | output | 1 | 26,011 | 1 | 52,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,012 | 1 | 52,024 |
Tags: flows, graphs, math
Correct Solution:
```
from collections import deque
from sys import stdin, stdout
MAX_SOLDIERS = 200000
def solve():
n, m = [int(_) for _ in stdin.readline().rstrip().split()]
all_lines = stdin.readlines()
start_vals = [int(_) for _ in all_lines[0].split()]
end_vals = [int(_... | output | 1 | 26,012 | 1 | 52,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,013 | 1 | 52,026 |
Tags: flows, graphs, math
Correct Solution:
```
class edge:
def __init__(self, node, capacity, flow, rev):
self.node = node
self.capacity = capacity
self.flow = flow
self.rev = rev
def __str__(self):
return (",".join([str(x) for x in
[self.node,
... | output | 1 | 26,013 | 1 | 52,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,014 | 1 | 52,028 |
Tags: flows, graphs, math
Correct Solution:
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class ford_fulkerson:
class Edge:
def __init__(self, to, cap, rev):
self.to = to
self.cap = cap
self.rev = rev
def __repr__(self):
return "to : {0} ... | output | 1 | 26,014 | 1 | 52,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,015 | 1 | 52,030 |
Tags: flows, graphs, math
Correct Solution:
```
from sys import stdin, stdout, stderr
from collections import deque
n,m = map(int,stdin.readline().split())
ai = [int(x) for x in stdin.readline().split()]
bi = [int(x) for x in stdin.readline().split()]
N = 2*n+2
M = 4*m + 6*n
cap = [None for i in range(M)]
flow = [0 f... | output | 1 | 26,015 | 1 | 52,031 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,016 | 1 | 52,032 |
Tags: flows, graphs, math
Correct Solution:
```
from collections import deque
import sys
n, m = input().split(' ')
n, m = int(n), int(m)
starts = [int(x) for x in input().split(' ')]
ends = [int(x) for x in input().split(' ')]
num_soldiers = sum(ends)
if sum(starts) != sum(ends):
print("NO")
sys.exit()
# 0 fo... | output | 1 | 26,016 | 1 | 52,033 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,017 | 1 | 52,034 |
Tags: flows, graphs, math
Correct Solution:
```
"""
Author: Andrew Jakubowicz
Problem: Soldier and Traveling
link: http://codeforces.com/problemset/problem/546/E#
n cities and m roads.
Each city has an army.
i-th city has a_i soldiers.
Soldiers can move at **most** one road or stay put.
"""
import math
class Edg... | output | 1 | 26,017 | 1 | 52,035 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one ... | instruction | 0 | 26,018 | 1 | 52,036 |
Tags: flows, graphs, math
Correct Solution:
```
from sys import stdin
from collections import deque
def bfs(g, el, source, dest, pre):
q = deque()
pre.clear()
pre.extend([None] * len(g))
q.append(source)
while q:
u = q.popleft()
for e in g[u]:
v, c, f = el[e][1], el[e][2], el[e][3]
if pre[v] is None and... | output | 1 | 26,018 | 1 | 52,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has ... | instruction | 0 | 26,019 | 1 | 52,038 |
Yes | output | 1 | 26,019 | 1 | 52,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has ... | instruction | 0 | 26,020 | 1 | 52,040 |
Yes | output | 1 | 26,020 | 1 | 52,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has ... | instruction | 0 | 26,021 | 1 | 52,042 |
Yes | output | 1 | 26,021 | 1 | 52,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has ... | instruction | 0 | 26,022 | 1 | 52,044 |
Yes | output | 1 | 26,022 | 1 | 52,045 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.