s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s202188059
p02234
u150984829
1519864586
Python
Python3
py
Accepted
100
5720
351
import sys def s(): n=int(input())+1 e=list(map(lambda x:x.split(),sys.stdin)) p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print(m[r][...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,582
s219272494
p02234
u150984829
1519864706
Python
Python3
py
Accepted
90
5720
334
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print(m[r][c]) if'__main__'=...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,583
s483729387
p02234
u150984829
1519864710
Python
Python3
py
Accepted
90
5720
334
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print(m[r][c]) if'__main__'=...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,584
s981800837
p02234
u150984829
1519864881
Python
Python3
py
Accepted
100
5720
311
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print(m[r][c]) s()
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,585
s649363498
p02234
u150984829
1519864884
Python
Python3
py
Accepted
100
5720
311
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print(m[r][c]) s()
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,586
s526543301
p02234
u150984829
1519864899
Python
Python3
py
Accepted
100
5712
334
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print(m[r][c]) if'__main__'=...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,587
s197580044
p02234
u150984829
1519864905
Python
Python3
py
Accepted
90
5720
334
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print(m[r][c]) if'__main__'=...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,588
s617125716
p02234
u150984829
1519869319
Python
Python3
py
Accepted
80
5712
329
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<=x:m[r][c]=x print(m[r][c]) if'__main__'==__na...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,589
s822726527
p02234
u150984829
1519869360
Python
Python3
py
Accepted
90
5716
328
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<x:m[r][c]=x print(m[r][c]) if'__main__'==__nam...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,590
s545193395
p02234
u150984829
1519869362
Python
Python3
py
Accepted
90
5712
328
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<x:m[r][c]=x print(m[r][c]) if'__main__'==__nam...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,591
s255460426
p02234
u150984829
1519869365
Python
Python3
py
Accepted
100
5716
328
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<x:m[r][c]=x print(m[r][c]) if'__main__'==__nam...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,592
s781258182
p02234
u150984829
1519869382
Python
Python3
py
Accepted
100
5716
329
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<=x:m[r][c]=x print(m[r][c]) if'__main__'==__na...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,593
s160314333
p02234
u150984829
1519869387
Python
Python3
py
Accepted
90
5720
329
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<=x:m[r][c]=x print(m[r][c]) if'__main__'==__na...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,594
s999922613
p02234
u912237403
1375389025
Python
Python
py
Accepted
100
4456
542
#coding: utf-8 import sys ROW = 0 COL = 1 def matrixchaincost(M): n = len(M) cost = [[0 for i in range(n)] for j in range(n)] for length in range(2, n+1): for i in range(0, n-length+1): k = i+length-1 def f(i,j,k): return cost[i][j-1]+cost[j][k]+M[i][ROW]*M...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,595
s806562659
p02234
u528682978
1592023410
Python
Python3
py
Accepted
100
5724
359
def solve(n,mat): dp=[[0]*n for _ in range(n)] for kukan in range(1,n): for i in range(n-kukan): dp[i][i+kukan]=min([dp[i][mid]+dp[mid+1][i+kukan]+mat[i][0]*mat[mid+1][0]*mat[i+kukan][1] for mid in range(i,i+kukan)]) return dp[0][n-1] n=int(input()) mat=[tuple(map(int,input().split())) ...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,596
s738465703
p02234
u450519077
1591369860
Python
Python3
py
Accepted
100
5664
377
import sys N = int(input()) R = [0]*N C = [0]*N for i in range(N): R[i], C[i] = map(int, input().split()) INF = 10**18 m = [[INF]*N for i in range(N)] for i in range(N): m[i][i] = 0 for l in range(1, N): for i in range(N-l): a0 = R[i] c0 = C[i+l] m[i][i+l] = min(a0*C[j]*c0 + m[i][j...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,597
s219073504
p02234
u067972379
1586185644
Python
Python3
py
Accepted
100
5668
360
N = int(input()) matrices = [tuple(map(int, input().split())) for _ in range(N)] R, C = zip(*matrices) dp = [[float('inf')] * N for _ in range(N)] for i in range(N): dp[i][i] = 0 for l in range(1, N): for i in range(N-l): r, c = R[i], C[i+l] dp[i][i+l] = min(r * C[j] * c + dp[i][j] + dp[j+1][i+l] fo...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,598
s889835869
p02234
u230072054
1584206577
Python
Python3
py
Accepted
80
5716
330
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<=x:m[r][c]=x print(m[r][c]) if'__main__'==__na...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,599
s684011750
p02234
u705234550
1582615781
Python
Python3
py
Accepted
100
5776
535
n = int(input()) M= [[] for i in range(n)] for i in range(n): M[i] = list(map(int, input().split())) p = [M[0][0]] for i in range(n): p.append(M[i][1]) f_inf = float("inf") m = [[f_inf for i in range(n)] for j in range(n)] def matrixChainOrder(n): for i in range(n): m[i][i] = 0 for l in range(2, n+1)...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,600
s046771104
p02234
u529459816
1576666262
Python
Python3
py
Accepted
100
5932
939
def main(): n = int(input()) m1 = input().split() ps = [int(m1[0]), int(m1[1])] for _ in range(n - 1): ps.append(int(input().split()[1])) ms = [[float("inf") for _ in range(n)] for __ in range(n)] # 範囲 0 - n for i in range(n): ms[i][i] = 0 for length in range(1, n): ...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,601
s815120822
p02234
u578043650
1574756045
Python
Python3
py
Accepted
100
5784
868
import sys class Mat(object): def __init__(self, row, col): self.row = row self.col = col def get_min_mult_cnt_dp(i, j, mat_list): multp = [[sys.maxsize for i in range(len(mat_list))] for i in range(len(mat_list))] # 長さ0連鎖の演算量 for i in range(len(mat_list)): multp[i][i] = 0 for le in...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,602
s032720605
p02234
u537758214
1571466619
Python
Python3
py
Accepted
80
5932
726
def main(): N = int(input()) p = [] for i in range(N): r, c = (int(i) for i in input().split()) p.append(r) if i == N - 1: p.append(c) memo = [[float('inf') for j in range(N + 1)] for i in range(N + 1)] def matrix_chain_order(): for i in range(1,N+1): ...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,603
s372709307
p02234
u778781355
1570939649
Python
Python3
py
Accepted
90
5752
552
def matrixChainMultiplication(): INF = 100 * 100 * 100 + 1 m = [[INF for _ in range(n + 1)] for _ in range(n + 1)] for i in range(1, n + 1): m[i][i] = 0 for l in range(2, n + 1): for i in range(1, n - l + 2): j = i + l - 1 for k in range(i, j): q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j] if q <...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,604
s290725295
p02234
u978863922
1543848821
Python
Python3
py
Accepted
100
6056
995
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_B&lang=jp # Matrix Chain Multiplication : python3 # 2018.12.03 yonezawa from collections import deque import sys input = sys.stdin.readline def main(): nmax = 1000000 n = int(input()) p = [] calc = [[nmax for i in range(n + 1)] for ...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,605
s733758246
p02234
u316584871
1541762659
Python
Python3
py
Accepted
20
5624
2,017
INF = 10**20 n = int(input()) nlist = [] all_mat = [] for i in range(n): a,b = map(int, input().split()) all_mat.append((a,b)) if (i == 0): nlist = [a,b] else: nlist.append(b) def cost1(nlist): if len(nlist) == 0: return 0 m = min(nlist) cost = 0 mid = nl...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,606
s222636287
p02234
u629780968
1536915028
Python
Python3
py
Accepted
80
5716
330
def s(): n=int(input())+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if not 0<m[r][c]<=x:m[r][c]=x print(m[r][c]) if'__main__'==__na...
p02234
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Matrix-chain Multiplication...
6 30 35 35 15 15 5 5 10 10 20 20 25
15125
28,607
s231298984
p02235
u880802684
1597377928
Python
Python3
py
Accepted
100
5636
1,069
# Longest Common Subsequence problem: LCS # https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/10/ALDS1_10_C import sys input = sys.stdin.readline ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' def get_LCS(x: str, y: str): lx = len(x) ly = len(y) dp = [[0] * (lx + 1) for _ in...
p02235
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Longest Common Subsequence<...
3 abcbdab bdcaba abc abc abc bc
4 3 2
28,608
s698417417
p02237
u255317651
1531014408
Python
Python3
py
Accepted
20
6408
464
# -*- coding: utf-8 -*- """ Created on Sun Jul 8 09:32:48 2018 @author: maezawa """ n = int(input()) adj = [[] for _ in range(n)] a = [[0 for _ in range(n)] for _ in range(n)] for j in range(n): ain = list(map(int, input().split())) u = ain[0] k = ain[1] for i in range(k): adj[u-1].append(a...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,609
s524476457
p02237
u609061402
1531294965
Python
Python3
py
Accepted
40
7104
340
n=int(input()) r=[[0 for i in range(n)]for j in range(n)] for i in range(n): a=list(map(int,input().split())) y=a[1] if y!=0: for j in range(2,2+y): r[i][a[j]-1]=1 for i in range(n): for j in range(n): if j!=0: print(" ",end="") print(r[i][j],end="") ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,610
s140279316
p02237
u684241248
1531470628
Python
Python3
py
Accepted
20
6396
205
# -*- coding: utf-8 -*- n = int(input()) g = [] for i in range(n): tmp = [int(_) for _ in input().split()[2:]] g.append([1 if v in tmp else 0 for v in range(1, n + 1)]) for _ in g: print(*_)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,611
s280052818
p02237
u424720817
1531793427
Python
Python3
py
Accepted
20
5684
258
n = int(input()) graph = [[0 for i in range(n)] for j in range(n)] for i in range(n): a = list(map(int, input().split())) for j in range(0, a[1], 1): graph[a[0] - 1][a[2 + j] - 1] = 1 for i in range(n): print(' '.join(map(str, graph[i])))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,612
s911458648
p02237
u424720817
1532060467
Python
Python3
py
Accepted
20
5680
258
n = int(input()) graph = [[0 for i in range(n)] for j in range(n)] for i in range(n): a = list(map(int, input().split())) for j in range(0, a[1], 1): graph[a[0] - 1][a[2 + j] - 1] = 1 for i in range(n): print(' '.join(map(str, graph[i])))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,613
s724393716
p02237
u279605379
1534723712
Python
Python3
py
Accepted
20
5676
252
n = int(input()) A = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): V = [int(i) for i in input().split()] for j in V[2:]: A[i][j-1] = 1 for i in A: tmp ="" for j in i: tmp+=str(j) + " " print(tmp[:-1])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,614
s893174426
p02237
u153665391
1534838613
Python
Python3
py
Accepted
20
5680
215
N = int(input()) adj = [[0 for j in range(N)] for i in range(N)] for _ in range(N): u, k, *v = input().split() for i in v: adj[int(u)-1][int(i)-1] = 1 for a in adj: print(" ".join(map(str, a)))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,615
s650679787
p02237
u726330006
1540438230
Python
Python3
py
Accepted
30
6392
322
n=int(input()) graph=[[0]*n for loop in range(n)] for loop in range(n): tmp_ope=list(map(int,input().split())) for j in range(tmp_ope[1]): graph[tmp_ope[0]-1][tmp_ope[j+2]-1]=1 for loop in range(n): for j in range(0,n-1): print(f"{graph[loop][j]}",end=" ") print(f"{graph[loop][n-1]}"...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,616
s206907542
p02237
u467648242
1545837029
Python
Python3
py
Accepted
20
5676
356
n = int(input()) in_list = [] for i in range(n): in_list.append(list(map(int, input().split()))) matrices = [["0" for _ in range(n)] for _ in range(n)] for i in range(n): inp = in_list[i] u = inp[0] k = inp[1] for j in range(k): m = inp[j+2] matrices[i][m-1] = "1" for i in range(n...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,617
s873085338
p02237
u357267874
1555811437
Python
Python3
py
Accepted
20
5680
244
n = int(input()) A = [[0 for i in range(n)] for j in range(n)] for i in range(n): u, k, *v = list(map(int, input().split())) for j in v: A[int(u)-1][int(j)-1] = 1 for row in A: msg = ' '.join(map(str, row)) print(msg)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,618
s700701861
p02237
u165578704
1556422469
Python
Python3
py
Accepted
20
6400
427
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10 ** 9) def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) INF=float('inf') N=INT() G=[[0]*N for i in range(N)] for i in range(N): l...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,619
s724350945
p02237
u694199042
1559035131
Python
Python3
py
Accepted
20
6384
292
n = int(input()) Adj = [ [] for _ in range(n) ] V = [] for i in range(n): V = list(map(int, input().split())) for i in range(V[1]): Adj[V[0]-1].append(V[2+i]) G = [ [0]*n for _ in range(n) ] for i in range(n): for j in Adj[i]: G[i][j-1] = 1 print(*G[i])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,620
s335459543
p02237
u970810709
1559096181
Python
Python3
py
Accepted
20
6388
210
n = int(input()) A = [[0 for i in range(n)] for i in range(n)] for _ in range(n): u, k, *v = [int(i) for i in input().split()] for vi in v: A[u-1][vi-1] = 1 for i in range(n): print(*A[i])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,621
s123443978
p02237
u821080069
1559308206
Python
Python3
py
Accepted
20
6388
285
n = int(input()) result = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): inp = list(map(int, input().split())) u, k = inp[0], inp[1] v = inp[2:] if k != 0: for vv in v: result[u-1][vv-1] = 1 result = list(result) for i in range(n): print(*result[i])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,622
s702833310
p02237
u244742296
1419816385
Python
Python3
py
Accepted
40
6764
866
class Graph: def __init__(self): self.edges = {} def addVertex(self, v): if v not in self.edges: self.edges[v] = [] def addEdge(self, from_v, to_v): if from_v not in self.edges: self.edges[from_v] = [] if to_v not in self.edges[from_v]: s...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,623
s442992100
p02237
u567380442
1422274845
Python
Python3
py
Accepted
40
6724
155
n = int(input()) for _ in range(n): v = list(map(int, input().split()))[2:] line = [0] * n for i in v: line[i - 1] = 1 print(*line)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,624
s920496558
p02237
u580607517
1422810838
Python
Python
py
Accepted
20
4296
248
n = int(raw_input()) x = [[0 for i in range(n)] for j in range(n)] for i in range(n): seq = map(int,raw_input().split()) tmp = seq[0]-1 n2 = seq[1] if n2!=0: for e in seq[2:]: x[tmp][e-1]=1 for i in range(n): print " ".join(map(str,x[i]))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,625
s334688866
p02237
u879226672
1430836486
Python
Python
py
Accepted
20
4292
259
n = int(raw_input()) mat = [[0 for i in range(n)] for j in range(n)] for i in range(n): ls = map(int,raw_input().split()) u = ls[0] k = ls[1] for m in range(k): mat[u-1][ls[2+m]-1] = 1 for item in mat: print ' '.join(map(str,item))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,626
s148851832
p02237
u809822290
1435890294
Python
Python3
py
Accepted
50
6796
371
from sys import stdin X = [ 0 for i in range(100) ] G = [[ 0 for i in range(100) ] for i in range(100)] n = int(input()) for i in range(n) : X[i] = stdin.readline().strip().split() for i in range(n) : for j in range(int(X[i][1])) : G[i][int(X[i][j+2])-1] = 1 for i in range(n) : for j in range(n) : if j != n...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,627
s094473678
p02237
u689297737
1436670478
Python
Python
py
Accepted
20
4308
599
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A # Graph # Result: import sys size = int(sys.stdin.readline().strip()) matrix = [0] * (size * size) for _ in range(0, size): vals = [int(x) for x in sys.stdin.readline().strip().split(' ')] if vals[1] == 0: continue idx = vals[0] - 1 ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,628
s149115170
p02237
u669360983
1439533073
Python
Python
py
Accepted
20
4288
265
n=int(raw_input()) #array=[[0]*n]*n arr=[[0 for i in range(n)] for j in range(n)] for i in range(n): a=list(map(int,raw_input().split())) if a[1]>0: for j in range(2,len(a)): arr[i][a[j]-1]=1 for i in range(n): for j in range(n): print arr[i][j], print
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,629
s745764346
p02237
u882992966
1442644298
Python
Python3
py
Accepted
40
7688
478
import sys if __name__ == "__main__": lines = sys.stdin.readlines() # Create n * n matrix dimension = int(lines[0]) matrix = [] for x in range(dimension): matrix.append([0] * dimension) # Set edge info for index, line in enumerate(lines[1:]): for edge in [int(x) for x in l...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,630
s720783671
p02237
u489809100
1447672951
Python
Python
py
Accepted
10
6412
269
n = int(raw_input()) graph = [[0 for i in xrange(n)] for j in xrange(n)] for i in xrange(n): fffff = map(int,raw_input().split()) y = fffff[0] - 1 for j in xrange(fffff[1]): graph[y][fffff[j + 2] - 1] = 1 for i in xrange(n): print " ".join(map(str, graph[i]))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,631
s017686614
p02237
u881590806
1450616764
Python
Python
py
Accepted
20
6444
277
n = int(raw_input()) for i in range(n): entry = map(int, raw_input().strip().split(' ')) u = entry[0] k = entry[1] neighbors = set(entry[2:]) for j in range(1,n+1): if j in neighbors: print 1, else: print 0, print
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,632
s205644958
p02237
u669284080
1451212244
Python
Python3
py
Accepted
30
7756
256
#!/usr/bin/python3 n = int(input()) A = [[0 for i in range(n)] for j in range(n)] for i in range(n): l = list(map(int, input().split())) u = l[0] V = l[2:] for v in V: A[u - 1][v - 1] = 1 for a in A: print(" ".join(map(str, a)))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,633
s455142981
p02237
u731976921
1453861472
Python
Python
py
Accepted
10
6448
324
import sys N = int(raw_input()) A = [0] * N for i in range(N): A[i] = [0] * N for line in sys.stdin: values = line.split() u = int(values[0]) - 1 k = int(values[1]) nodes = values[2:] for i in range(int(k)): v = int(nodes[i]) - 1 A[u][v] = 1 for i in range(N): print " ".join([str(x) for x in A[...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,634
s878381616
p02237
u797673668
1454251068
Python
Python3
py
Accepted
20
8456
199
n = int(input()) g = [[0] * n for _ in range(n)] while n: l = list(map(int, input().split())) cg = g[l[0] - 1] for i in l[2:]: cg[i - 1] = 1 n -= 1 for v in g: print(*v)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,635
s051167063
p02237
u731710433
1457009152
Python
Python3
py
Accepted
50
7816
225
n = int(input()) mat = [[0] * n for _ in range(n)] for _ in range(n): adj = list(map(int, input().split())) i = adj[0] for j in adj[2:]: mat[i - 1][j - 1] = 1 for m in mat: print(' '.join(map(str, m)))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,636
s552062559
p02237
u648595404
1458830971
Python
Python3
py
Accepted
20
7660
204
n = int(input()) for i in range(n): node = list(map(int,input().split())) node_list = node[2:] matrix = ["0"]* n for j in node_list: matrix[j -1] = "1" print(" ".join(matrix))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,637
s152838630
p02237
u072053884
1462506364
Python
Python3
py
Accepted
30
8476
234
n = int(input()) adj_mat = [[0 for i in range(n + 1)] for j in range(n)] for i in range(n): adj_list = list(map(int, input().split())) for j in adj_list[2:]: adj_mat[i][j] = 1 for a_l in adj_mat: print(*a_l[1:])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,638
s406403660
p02237
u072053884
1462506538
Python
Python3
py
Accepted
30
8508
252
n = int(input()) adj_mat = [[0 for i in range(n + 1)] for j in range(n)] for i in range(n): listed_input = list(map(int, input().split())) for j in listed_input[2:]: adj_mat[i][j] = 1 for adj_list in adj_mat: print(*adj_list[1:])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,639
s442110210
p02237
u072053884
1462510235
Python
Python3
py
Accepted
30
8420
234
n = int(input()) adj_mat = [[0 for i in range(n + 1)] for j in range(n)] for i in range(n): adj_list_i = list(map(int, input().split()[2:])) for j in adj_list_i: adj_mat[i][j] = 1 for r in adj_mat: print(*r[1:])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,640
s959588380
p02237
u072053884
1462510592
Python
Python3
py
Accepted
30
8448
222
n = int(input()) adj_mat = [[0] * (n + 1) for j in range(n)] for i in range(n): adj_list_i = list(map(int, input().split()[2:])) for j in adj_list_i: adj_mat[i][j] = 1 for r in adj_mat: print(*r[1:])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,641
s513971184
p02237
u567281053
1463068566
Python
Python
py
Accepted
10
6504
394
import sys def list2mat(V, n): M = [[0] * (n) for _ in range(n)] for i in range(1, n + 1): for v in V[i]: M[i - 1][v - 1] = 1 return M lines = sys.stdin.readlines() n = int(lines[0]) V = [[0] for _ in range(n + 1)] for i in range(1, n + 1): v = map(int, lines[i].split()) V[v[0...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,642
s154745752
p02237
u744522373
1463226587
Python
Python
py
Accepted
10
6420
220
import sys,re d = int(sys.stdin.readline().strip()) for line in sys.stdin: cols = line.strip().split(' ') out = [ "0" for i in range(d) ] for n in cols[2:]: out[int(n)-1]="1" print " ".join(out)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,643
s179123056
p02237
u569960318
1467858999
Python
Python3
py
Accepted
30
7656
150
n = int(input()) for _ in range(n): u = list(map(int,input().split())) out = [0]*n for i in range(u[1]): out[u[i+2]-1] = 1 print(*out)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,644
s524618686
p02237
u569960318
1467859291
Python
Python3
py
Accepted
20
7660
139
n = int(input()) for _ in range(n): u = list(map(int,input().split())) out = [0]*n for i in u[2:]: out[i-1] = 1 print(*out)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,645
s869913712
p02237
u984009739
1467860366
Python
Python3
py
Accepted
30
7680
214
n = int(input()) v = [[0]*n for _ in range(n)] for i in range(n): l = list(map(int,input().split())) u = l[0] k = l[1] c = l[2:] for j in c: v[u-1][j-1]=1 for m in v: print(' '.join(map(str, m)))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,646
s059865026
p02237
u890722286
1476177956
Python
Python3
py
Accepted
30
8480
283
n = int(input()) l = [[0 for _ in range(n + 1)] for _ in range(n + 1)] for i in range(n + 1): if i == 0: continue u = list(map(int, input().split())) for x in u[2:]: l[i][x] = 1 for i in range(n + 1): if i == 0: continue print(*l[i][1:])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,647
s916270769
p02237
u027872723
1476641542
Python
Python3
py
Accepted
40
9048
454
# -*- coding: utf_8 -*- level = False def debug(v): if level: print(v) n = int(input()) a = [] for i in range(n): v = input().split() v.pop(0) v.pop(0) a.append([int(x) for x in v]) debug(a) for i in range(0, n): v = a[i] for j in range(n): if (j + 1) in v: p...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,648
s136453659
p02237
u460172144
1477241642
Python
Python3
py
Accepted
40
8400
216
n = int(input()) GM = [[0]*n for i in range(n)] for i in range(n): data = list(map(int,input().split())) for i in range(data[1]): GM[data[0]-1][data[i+2]-1] = 1 for i in range(n): print(*GM[i])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,649
s989902238
p02237
u022407960
1479575126
Python
Python3
py
Accepted
20
8372
605
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def generate_graph(v_info): for info in v_info: adj_info = info[2:] for each in adj_info: adj_matrix[int(info[0]) - 1][int(each) - 1] = 1 return adj_matrix if __name__ == '__main__': _input = sys.stdin.readlines() ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,650
s401752306
p02237
u022407960
1479575223
Python
Python3
py
Accepted
60
8416
605
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def generate_graph(v_info): for info in v_info: adj_info = info[2:] for each in adj_info: adj_matrix[int(info[0]) - 1][int(each) - 1] = 1 return adj_matrix if __name__ == '__main__': _input = sys.stdin.readlines() ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,651
s183013244
p02237
u022407960
1479575250
Python
Python3
py
Accepted
50
8520
605
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def generate_graph(v_info): for info in v_info: adj_info = info[2:] for each in adj_info: adj_matrix[int(info[0]) - 1][int(each) - 1] = 1 return adj_matrix if __name__ == '__main__': _input = sys.stdin.readlines() ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,652
s603209686
p02237
u022407960
1479576480
Python
Python3
py
Accepted
30
8344
650
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def generate_graph(v_info): for info in v_info: adj_info = info[2:] assert len(adj_info) == int(info[1]) for each in adj_info: adj_matrix[int(info[0]) - 1][int(each) - 1] = 1 return adj_matrix if __name__ == '__ma...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,653
s849059495
p02237
u159356473
1480322502
Python
Python3
py
Accepted
50
8140
545
#coding:utf-8 def Graph(n,A): ans=[] for i in range(n): line=[] for j in range(n): line.append(0) ans.append(line) for i in range(n): if A[i][1]!=0: for j in range(A[i][1]): ans[i][A[i][2+j]-1]=1 for i in range(n): for j in ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,654
s882694503
p02237
u186082958
1480518038
Python
Python3
py
Accepted
30
8416
361
N=int(input()) ad_ma=[[0 for i in range(N)] for j in range(N)] for i in range(N): nums=list(map(lambda x:int(x)-1,input().split())) f=nums[0] nums=nums[2:] for num in nums: ad_ma[f][num]=1 for i in range(N): for j in range(N): if(j!=N-1): print(ad_ma[i][j],end=' ') ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,655
s216835394
p02237
u811733736
1481064458
Python
Python3
py
Accepted
20
8508
445
if __name__ == '__main__': # ??????????????\??? num = int(input()) data = [] for _ in range(num): data.append(list(map(int, input().split(' ')))) # ??????????????? graph_table = [[0]*num for _ in range(num)] for d in data: node_id = d[0] num_of_e = d[1] for e...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,656
s776458618
p02237
u564398841
1485070335
Python
Python3
py
Accepted
20
7744
360
if __name__ == '__main__': N = int(input()) matrix = [['0'] * N for _ in range(N)] for i in matrix: node_info = [int(i) for i in input().split()] node_i = node_info[0] - 1 if not node_info[1] == 0: for i in node_info[2:]: matrix[node_i][i - 1] = '1' [p...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,657
s578397796
p02237
u923668099
1486097306
Python
Python3
py
Accepted
20
8420
514
import sys def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): n = int(input()) edge = [[0]*n for i in range(n)] for i in range(n): u, k, *vs = [int(j) - 1 for j i...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,658
s292641339
p02237
u078042885
1486880738
Python
Python3
py
Accepted
20
7588
113
n=int(input()) for _ in [0]*n: a=[0]*n for i in list(map(int,input().split()))[2:]:a[i-1]=1 print(*a)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,659
s869710081
p02237
u112247126
1488246833
Python
Python3
py
Accepted
30
7764
471
import sys class Graph: def __init__(self, nodes={}): self.nodes = nodes n = int(input()) G = Graph() for line in sys.stdin: numList = list(map(int, line.split())) G.nodes[numList[0]] = list(numList[2:]) for node in range(n): out = '' for adj in range(n): if adj + 1 != n: ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,660
s516236524
p02237
u854976463
1489404954
Python
Python
py
Accepted
10
6400
808
n = int(raw_input()) GMatrix = [[0]*n for i in range(n)] GList = {} for i in range(n): ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,661
s084620240
p02237
u228579910
1489587293
Python
Python3
py
Accepted
20
8392
208
n = int(input()) g = [[0] * n for _ in range(n)] while n: l = list(map(int, input().split())) column_g = g[l[0] - 1] for i in l[2:]: column_g[i-1] = 1 n -= 1 for v in g: print(*v)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,662
s320912625
p02237
u851695354
1489834646
Python
Python3
py
Accepted
30
8376
397
N = int(input()) # initialize ans = [[0 for i in range(N)] for j in range(N)] for i in range(N): a = list(map(int, input().split())) id = a[0] jisu = a[1] for j in range(jisu): c = a[j+2] ans[i][c-1] = 1 for i in range(N): for j in range(N): if j != N-1: print...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,663
s477876979
p02237
u851695354
1491817610
Python
Python3
py
Accepted
30
8352
654
""" Main?????????????????? """ # Node??°????????? N = int(input()) # Node?????????????????????????????? nodes = [[0 for i in range(N)] for j in range(N)] # Node??????????¨???? for i in range(N): j = list(map(int, input().split())) # ??\??????????§£ no = j[0] - 1 # Node??????????????? ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,664
s902197837
p02237
u089830331
1494890601
Python
Python3
py
Accepted
30
8408
184
n = int(input()) G = [[0] * n for _ in range(n)] for _ in range(n): V = list(map(int, input().split())) u = V[0] for v in V[2:]: G[u - 1][v - 1] = 1 for i in G: print(*i)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,665
s198363454
p02237
u603049633
1496483913
Python
Python3
py
Accepted
20
7728
269
n = int(input()) Adj = [[0 for i in range(n)] for i in range(n)] for i in range(n): u = list(map(int, input().split())) if u[1] > 0: for i in u[2: 2 + u[1]]: Adj[u[0] - 1][i - 1] = 1 for i in range(n): print(" ".join(map(str, Adj[i])))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,666
s359085708
p02237
u371539389
1496660042
Python
Python3
py
Accepted
30
7736
243
n=int(input()) V=[[0 for i in range(n)] for j in range(n)] for i in range(n): v=[int(j) for j in input().split(" ")] u=v.pop(0) k=v.pop(0) for j in range(k): V[u-1][v[j]-1]=1 for i in range(n): print(" ".join([str(j) for j in V[i]]))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,667
s603737624
p02237
u370086573
1497077862
Python
Python3
py
Accepted
20
8444
492
def convertList(G): n = len(G) GL = [ [0 for _ in range(n)] for _ in range(n)] for key, values in G.items(): GL[key - 1][key - 1] = 0 for v in values: GL[key - 1][v - 1] = 1 return GL if __name__ == '__main__': G = {} n = int(input()) for _ in range(n): ...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,668
s810306327
p02237
u067677727
1498821414
Python
Python3
py
Accepted
20
7732
311
n = int(input()) adj = [[0 for i in range(n)] for j in range(n)] for i in range(n): tmp = list(map(int, input().split())) u = tmp[0] u = u -1 k = tmp[1] v = tmp[2:] for j in range(k): adj[u][v[j]-1] = 1 for i in range(n): print(" ".join(list(map(str, adj[i]))))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,669
s820746948
p02237
u067677727
1498880069
Python
Python3
py
Accepted
30
8528
365
def main(): n = int(input()) adj = [[0 for i in range(n)] for j in range(n)] for i in range(n): tmp = list(map(int, input().split())) u = tmp[0] u = u -1 k = tmp[1] v = tmp[2:] for j in range(k): adj[u][v[j]-1] = 1 for i in adj: prin...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,670
s196905105
p02237
u426534722
1499355183
Python
Python3
py
Accepted
30
8524
254
from sys import stdin n = int(stdin.readline()) v = [[0] * (n + 1) for i in range(n + 1)] for u in range(1, n + 1): U = [int(j) for j in stdin.readline().split()] for k in U[2:]: v[u][k] += 1 for i in range(1, n + 1): print(*v[i][1:])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,671
s874170620
p02237
u426534722
1499355966
Python
Python3
py
Accepted
20
8400
208
from sys import stdin n = int(stdin.readline()) v = [[0] * n for _ in range(n)] for u in range(n): l = list(map(int, stdin.readline().split())) for k in l[2:]: v[u][k - 1] = 1 print(*v[u])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,672
s358295286
p02237
u426534722
1499356112
Python
Python3
py
Accepted
30
8448
210
from sys import stdin n = int(stdin.readline()) v = [[0] * n for _ in range(n)] for u in range(n): l = [int(j) for j in stdin.readline().split()] for k in l[2:]: v[u][k - 1] = 1 print(*v[u])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,673
s847938827
p02237
u091533407
1500379286
Python
Python3
py
Accepted
20
7728
311
import sys if __name__ == "__main__": n = int(sys.stdin.readline()) ANS = [[0] * n for i in range(n)] for inp in sys.stdin.readlines(): inp = list(map(int, inp.split())) for i in inp[2:]: ANS[inp[0]-1][i-1] = 1 for row in ANS: print(" ".join(map(str, row)))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,674
s260027374
p02237
u533883485
1500975559
Python
Python3
py
Accepted
20
8428
294
# coding=utf-8 n = int(input()) M = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): u, k, *v = map(int, input().split()) u = u-1 #for index if k == 0: continue for num in v: num = num-1 #for index M[u][num] = 1 for row in M: print(*row)
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,675
s348713951
p02237
u491916705
1502723989
Python
Python
py
Accepted
10
6448
264
n = int(raw_input()) a = [[0 for i in range(n)] for j in range(n)] for i in range(n): tmp = map(int, raw_input().split()) if tmp[1]: for j in range(1, tmp[1]+1): a[i][tmp[j+1]-1] = 1 for i in range(n): print ' '.join(map(str, a[i]))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,676
s016914813
p02237
u510829608
1502852920
Python
Python3
py
Accepted
20
8488
292
N = int(input()) dp = [[0 for i in range(N)] for j in range(N)] for _ in range(N): inputs = list(map(int, input().split())) u = inputs[0] k = inputs[1] v = inputs[2:] #print(u, k, v) for each in v: dp[u-1][each-1] = 1 for i in range(N): print(*dp[i][:])
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,677
s130796742
p02237
u939814144
1502935849
Python
Python3
py
Accepted
20
7644
266
def adjmatrices(): n = int(input()) for i in range(n): node_list = list(map(int, input().split())) matrix = [0]*n for j in node_list[2:]: matrix[j-1] = 1 print(*matrix) if __name__ == '__main__': adjmatrices()
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,678
s208090399
p02237
u855199458
1502963692
Python
Python3
py
Accepted
20
7748
230
# -*- coding: utf-8 -*- N = int(input()) adj = [["0"]*N for _ in range(N)] for _ in range(N): inp = list(map(int, input().split())) for i in inp[2:]: adj[inp[0]-1][i-1] = "1" for a in adj: print(" ".join(a))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,679
s657033730
p02237
u810434660
1504013919
Python
Python3
py
Accepted
50
7680
482
# coding: utf-8 n = int(input().rstrip()) for i in range(n): line = input().rstrip().split(" ") lineMax = int(line[1]) lineIndex = 0 for j in range(n): if lineIndex >= lineMax: print(0, end = "") else: if j + 1 == int(line[lineIndex + 2]): print(1...
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,680
s970055302
p02237
u519227872
1504099351
Python
Python3
py
Accepted
20
7672
245
n = int(input()) M = [[0] * n for i in range(n)] for i in range(n): t = list(map(int, input().split())) v = t[0] k = t[1] for j in range(k): M[v - 1][t[2+j] - 1] = 1 for r in M: r = map(str, r) print(' '.join(r))
p02237
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"> </script> <H1>Graph</H1> <p> There are t...
4 1 2 2 4 2 1 4 3 0 4 1 3
0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0
28,681