message
stringlengths
2
49.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
446
108k
cluster
float64
13
13
__index_level_0__
int64
892
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the colo...
instruction
0
53,712
13
107,424
Yes
output
1
53,712
13
107,425
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the colo...
instruction
0
53,713
13
107,426
Yes
output
1
53,713
13
107,427
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the colo...
instruction
0
53,714
13
107,428
Yes
output
1
53,714
13
107,429
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the colo...
instruction
0
53,715
13
107,430
No
output
1
53,715
13
107,431
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the colo...
instruction
0
53,716
13
107,432
No
output
1
53,716
13
107,433
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the colo...
instruction
0
53,717
13
107,434
No
output
1
53,717
13
107,435
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the colo...
instruction
0
53,718
13
107,436
No
output
1
53,718
13
107,437
Provide a correct Python 3 solution for this coding contest problem. Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i. He will play Q rounds of a game using this graph. In the i-th rou...
instruction
0
53,799
13
107,598
"Correct Solution: ``` import sys input = sys.stdin.readline from operator import itemgetter from collections import deque class Unionfindtree: def __init__(self, number): self.par = [i for i in range(number)] self.rank = [0] * (number) def find(self, x): # 親を探す if self.par[x] == x: ...
output
1
53,799
13
107,599
Provide a correct Python 3 solution for this coding contest problem. Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i. He will play Q rounds of a game using this graph. In the i-th rou...
instruction
0
53,800
13
107,600
"Correct Solution: ``` from collections import deque import sys sys.setrecursionlimit(10**5) N, M = map(int, input().split()) E = [] for i in range(M): a, b, c = map(int, input().split()) E.append((c, a-1, b-1)) E.sort() *p, = range(N) def root(x): if x == p[x]: return x p[x] = y = root(p[x]) ...
output
1
53,800
13
107,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i. He will p...
instruction
0
53,801
13
107,602
No
output
1
53,801
13
107,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i. He will p...
instruction
0
53,802
13
107,604
No
output
1
53,802
13
107,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i. He will p...
instruction
0
53,803
13
107,606
No
output
1
53,803
13
107,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i. He will p...
instruction
0
53,804
13
107,608
No
output
1
53,804
13
107,609
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,985
13
107,970
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` MOD = 998244353 def main(): buf = input() n = int(buf) edge = dict() for i in range(n): edge[i] = [] # zero index for i in range(n-1): buf = input() buflist = list(buf.split()) a = int(buflist[0])...
output
1
53,985
13
107,971
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,986
13
107,972
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` from sys import stdin, exit from collections import defaultdict input = stdin.readline n = int(input()) edge = [tuple(map(int, line.split())) for line in stdin.read().splitlines()] res = n d = defaultdict(int) MOD = 998244353 for u, v in edge: ...
output
1
53,986
13
107,973
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,987
13
107,974
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def main(): N = 10**6 mod = 998244353 fac = [1]*(N+1) finv = [1]*(N+1) for i in range(N): fac[i+1] = fac[i] * (i+1) % mod finv[-1] ...
output
1
53,987
13
107,975
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,988
13
107,976
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` import sys n = int(sys.stdin.readline().strip()) D = [0] * n p = 998244353 for i in range (0, n - 1): u, v = list(map(int, sys.stdin.readline().strip().split())) D[u-1] = D[u-1] + 1 D[v-1] = D[v-1] + 1 ans = n for i in range (0, n): ...
output
1
53,988
13
107,977
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,989
13
107,978
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` import io, os #input = io.StringIO(os.read(0, os.fstat(0).st_size).decode()).readline g = [0] * 200005 r = int(input()) n = r for i in range(1, n): u, v = map(int, input().split()) g[u] += 1 g[v] += 1 r *= g[u] * g[v] r %= 998244353 print(r...
output
1
53,989
13
107,979
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,990
13
107,980
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` # Enter your code here. Read input from STDIN. Print output to STDOUT# =============================================================================================== # importing some useful libraries. from __future__ import division, print_function ...
output
1
53,990
13
107,981
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,991
13
107,982
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` import sys input=sys.stdin.readline #sys.setrecursionlimit(1000000) n=int(input()) fr=[0]*(n+2) fr[0]=1 d=[0]*(n+2) mod=int(998244353) for i in range(1,n+1): fr[i]=(fr[i-1]*i)%mod for i in range(n-1): u,v=map(int,input().split()) d[u...
output
1
53,991
13
107,983
Provide tags and a correct Python 3 solution for this coding contest problem. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nodes are numbered from 1 to n. Nauuo wants to dr...
instruction
0
53,992
13
107,984
Tags: combinatorics, dfs and similar, dp, trees Correct Solution: ``` import math def factorial(n,j): inf=998244353 j[0]=1 j[1]=1 for i in range(2,n+1): j[i]=j[i-1]*i j[i]%=inf return j l1=[0]*(200009) y=factorial(200008,l1) inf=998244353 n=int(input()) l=[0]*(200009) x=1 for i in ...
output
1
53,992
13
107,985
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
53,993
13
107,986
Yes
output
1
53,993
13
107,987
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
53,994
13
107,988
Yes
output
1
53,994
13
107,989
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
53,995
13
107,990
Yes
output
1
53,995
13
107,991
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
53,996
13
107,992
Yes
output
1
53,996
13
107,993
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
53,997
13
107,994
No
output
1
53,997
13
107,995
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
53,998
13
107,996
No
output
1
53,998
13
107,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
53,999
13
107,998
No
output
1
53,999
13
107,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
54,000
13
108,000
No
output
1
54,000
13
108,001
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. Nauuo is a girl who loves drawing circles. One day she has drawn a circle and wanted to draw a tree on it. The tree is a connected undirected graph consisting of n nodes and n-1 edges. The nod...
instruction
0
54,001
13
108,002
No
output
1
54,001
13
108,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The graph is called tree if it is connected and has no cycles. Suppose the tree is rooted at some vertex. Then tree is called to be perfect k-ary tree if each vertex is either a leaf (has no chi...
instruction
0
54,804
13
109,608
No
output
1
54,804
13
109,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The graph is called tree if it is connected and has no cycles. Suppose the tree is rooted at some vertex. Then tree is called to be perfect k-ary tree if each vertex is either a leaf (has no chi...
instruction
0
54,805
13
109,610
No
output
1
54,805
13
109,611
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The graph is called tree if it is connected and has no cycles. Suppose the tree is rooted at some vertex. Then tree is called to be perfect k-ary tree if each vertex is either a leaf (has no chi...
instruction
0
54,806
13
109,612
No
output
1
54,806
13
109,613
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The graph is called tree if it is connected and has no cycles. Suppose the tree is rooted at some vertex. Then tree is called to be perfect k-ary tree if each vertex is either a leaf (has no chi...
instruction
0
54,807
13
109,614
No
output
1
54,807
13
109,615
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that we have an array of n distinct numbers a_1, a_2, ..., a_n. Let's build a graph on n vertices as follows: for every pair of vertices i < j let's connect i and j with an edge, if a_i ...
instruction
0
54,909
13
109,818
No
output
1
54,909
13
109,819
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the token from vertex u to vertex v if there is an e...
instruction
0
54,973
13
109,946
Tags: dfs and similar, graphs, greedy, shortest paths Correct Solution: ``` import sys input = sys.stdin.readline import heapq mod=998244353 n,m=map(int,input().split()) E=[[] for i in range(n+1)] E2=[[] for i in range(n+1)] for i in range(m): x,y=map(int,input().split()) E[x].append(y) E2[y].append(x) ...
output
1
54,973
13
109,947
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the token from vertex u to vertex v if there is an e...
instruction
0
54,974
13
109,948
Tags: dfs and similar, graphs, greedy, shortest paths Correct Solution: ``` from heapq import heappush, heappop;mod = 998244353;N, M = map(int, input().split());E1 = [[] for _ in range(N)];E2 = [[] for _ in range(N)] for _ in range(M):u, v = map(int, input().split());u -= 1;v -= 1;E1[u].append(v);E2[v].append(u) mask1 ...
output
1
54,974
13
109,949
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the token from vertex u to vertex v if there is an e...
instruction
0
54,975
13
109,950
Tags: dfs and similar, graphs, greedy, shortest paths Correct Solution: ``` # region fastio # from https://codeforces.com/contest/1333/submission/75948789 import sys, io, os BUFSIZE = 8192 class FastIO(io.IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer =...
output
1
54,975
13
109,951
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the token from vertex u to vertex v if there is an e...
instruction
0
54,976
13
109,952
Tags: dfs and similar, graphs, greedy, shortest paths Correct Solution: ``` #!/usr/bin/env python import os import sys from io import BytesIO, IOBase pow2 = [1] for i in range(30): pow2.append(pow2[-1] * 2) class distance(object): def __init__(self, val1: int,val2: int): self.val1 = val1 self....
output
1
54,976
13
109,953
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the t...
instruction
0
54,977
13
109,954
No
output
1
54,977
13
109,955
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the t...
instruction
0
54,978
13
109,956
No
output
1
54,978
13
109,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the t...
instruction
0
54,979
13
109,958
No
output
1
54,979
13
109,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1. The following actions are allowed: * Token movement. To move the t...
instruction
0
54,980
13
109,960
No
output
1
54,980
13
109,961
Provide a correct Python 3 solution for this coding contest problem. Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edg...
instruction
0
55,406
13
110,812
"Correct Solution: ``` from collections import defaultdict, deque def grouping(n, N, d): group = [-1]*(N+1) group[n] = 1 q = deque([n]) while q: s = q.popleft() for t in d[s]: if group[t]!=-1:continue group[t] = group[s] + 1 q.append(t) for k, ...
output
1
55,406
13
110,813
Provide a correct Python 3 solution for this coding contest problem. Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edg...
instruction
0
55,407
13
110,814
"Correct Solution: ``` N = int(input()) S = [list(map(int,list(input()))) for _ in [0]*N] E = [[] for _ in [0]*N] for i,row in enumerate(S): for j,s in enumerate(row): if s : E[i].append(j) def dist_bfs(N,E,start): d = [-1]*N d[start] = 0 q = [start] while q: qq = [] ...
output
1
55,407
13
110,815
Provide a correct Python 3 solution for this coding contest problem. Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edg...
instruction
0
55,408
13
110,816
"Correct Solution: ``` from collections import deque N = int(input()) minDist = [[1 if s == '1' else float('inf') for s in input()] for _ in range(N)] for i in range(N): minDist[i][i] = 0 for k in range(N): for i in range(N): for j in range(N): if minDist[i][j] > minDist[i][k] + minDist[...
output
1
55,408
13
110,817
Provide a correct Python 3 solution for this coding contest problem. Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edg...
instruction
0
55,409
13
110,818
"Correct Solution: ``` from collections import deque n = int(input()) s = [list(map(int, list(input()))) for _ in range(n)] bord = [[] for _ in range(n)] for i in range(n-1): for j in range(i+1, n): if s[i][j]==1: bord[i].append(j) bord[j].append(i) result = [] for i in range(n): ...
output
1
55,409
13
110,819
Provide a correct Python 3 solution for this coding contest problem. Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edg...
instruction
0
55,410
13
110,820
"Correct Solution: ``` n = int(input()) raw = [] for i in range(n): tmp = input() now = [] for j in range(n): if tmp[j] == '1': now.append(j) raw.append(now) #print(raw) ans = [] for st in range(n): gr = [-1 for _ in range(n)] gr[st] = 1 time = 1 now = {st} while now: time += 1 last ...
output
1
55,410
13
110,821
Provide a correct Python 3 solution for this coding contest problem. Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edg...
instruction
0
55,411
13
110,822
"Correct Solution: ``` def b(u,x): c[u]=x return all((c[u]!=c[v])&(c[v]or b(v,-x))for v in X if d[u][v]==1) N=int(input()) X=range(N) S=[input()for _ in X] d=[[1 if S[i][j]=='1'else(N if i^j else 0)for j in X]for i in X] for k in X: for i in X: for j in X:d[i][j]=min(d[i][j],d[i][k]+d[k][j]) c=[0]*N print(max(max(...
output
1
55,411
13
110,823
Provide a correct Python 3 solution for this coding contest problem. Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edg...
instruction
0
55,412
13
110,824
"Correct Solution: ``` N = int(input()) g = [[] for i in [0]*(N+1)] for i in range(1,N+1): S = input() for j in range(1,i+1): if S[j-1] == '1': g[i].append(j) g[j].append(i) def max_len(g,v): visited = [False]*(N+1) l = 1 ls = [v] pre_v = [] while(ls): ...
output
1
55,412
13
110,825