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
s556747295
p02237
u590535211
1589289149
Python
Python3
py
Accepted
20
6388
248
n = int(input()) Adj = [[] for _ in range(n+1)] C = [[0]*(n+1) for _ in range(n+1)] for i in range(n): tmp = list(map(int,input().split())) for j in range(tmp[1]): C[tmp[0]][tmp[2+j]] = 1 for i in range(n): print(*C[i+1][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,782
s423329087
p02237
u083949342
1588436301
Python
Python3
py
Accepted
20
5620
337
def main(): n = int(input()) rows = [] for i in range(n): rows.append([int(x) for x in input().split()]) for row in rows: u,k = row[0],row[1] ul = [0]*n for j in range(k): ul[row[j+2]-1] = 1 print(' '.join([str(u) for u in ul])) if __name__ == '__main...
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,783
s101039926
p02237
u486183171
1588295577
Python
Python3
py
Accepted
20
6380
200
N = int(input()) G = [[0] * N for _ in range(N)] for _ in range(N): u, n, *K = map(int, input().split()) u -= 1 for k in K: k -= 1 G[u][k] = 1 for g in G: print(*g)
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,784
s957125694
p02237
u720435112
1588145772
Python
Python3
py
Accepted
20
5676
239
n = int(input()) graph = [[0]*n for _ in range(n)] for _ in range(n): u, k, *V = map(int, input().split()) if k == 0: continue for j in V: graph[u-1][j-1] = 1 for g in graph: print(' '.join(map(str, g)))
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,785
s905001925
p02237
u713172874
1588130282
Python
Python3
py
Accepted
20
6388
210
n = int(input()) graph = [[0 for i in range(n)] for j in range(n)] for i in range(n): v = list(map(int,input().split())) for j in v[2:]: graph[v[0]-1][j-1] = 1 for i in graph: 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,786
s762139323
p02237
u940492895
1588015443
Python
Python3
py
Accepted
30
6384
321
# 幅優先探索 Breadth first search: BFS n = int(input()) A = [[0 for i in range(n)] for i in range(n)] for i in range(n): dat = [int(i) for i in input().split()] for v in dat[2:]: A[dat[0]-1][v-1] = 1 for i in range(n): for j in range(n-1): print(A[i][j], end=" ") print(A[i][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,787
s918941183
p02237
u157179698
1587898893
Python
Python3
py
Accepted
20
5660
324
import sys input=sys.stdin.buffer.readline N = int(input()) M = [[0]*N for _ in range(N)] for _ in range(N): nums = list(map(int,input().split())) a = nums[1] if a == 0: continue else: for j in nums[2:]: M[nums[0]-1][j-1] = 1 for i in range(N): print(" ".join(map(str,M[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,788
s625018753
p02237
u994919098
1587587753
Python
Python3
py
Accepted
20
5612
327
n = int(input()) L = [[] for _ in range(n)] for i in range(n): L[i] = [i for i in map(int,input().split())] L[i].remove(L[i][0]) if L[i] != []: L[i].remove(L[i][0]) for i in range(n): adjacent = [0 for _ in range(n)] for el in L[i]: adjacent[el-1] = 1 print(' '.join(map(str,adjac...
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,789
s937488543
p02237
u548252256
1586957996
Python
Python3
py
Accepted
20
6384
236
if __name__ == '__main__': n = int(input()) A = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): cmd = input().split(); m = int(cmd[1]) for j in range(m): A[i][int(cmd[2+j])-1] = 1 for i in A: 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,790
s559009072
p02237
u862284621
1585994759
Python
Python3
py
Accepted
20
6380
326
def main(): n = int(input()) adjacency_matrix = [] for _ in range(n): u, k, *V = map(int, input().split()) col = [0] * n for v in V: col[v-1] = 1 adjacency_matrix.append(col) for col in adjacency_matrix: print(*col) if __name__ == "__main__": 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,791
s329380394
p02237
u820842907
1585803388
Python
Python3
py
Accepted
20
6380
277
def Main(): N = int(input()) adj = [[0]*N for i in range(N)] for n in range(N): u, k, *V = map(int, input().split()) if k > 0: for i in V: adj[u - 1][i - 1] = 1 for i in range(N): print(*adj[i]) Main()
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,792
s423893097
p02237
u258049727
1585801606
Python
Python3
py
Accepted
20
6384
206
n = int(input()) M = [["0"]*n for _ in range(n)] for _ in range(n): i = [int(i) for i in input().split()] u = i[0] k = i[1] V = i[2:] for v in V: M[u-1][v-1] = "1" for i in M: 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,793
s887997698
p02237
u737337423
1585731624
Python
Python3
py
Accepted
20
6392
244
# Graph import sys input = sys.stdin.readline n = int(input()) A = [tuple(map(int, input().split())) for _ in range(n)] G = [[0]*(n) for _ in [0]*(n)] for i, k, *V in A: for v in V: G[i-1][v-1] = 1 for g in G: print(*g)
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,794
s141104259
p02237
u891183253
1585712809
Python
Python3
py
Accepted
20
6396
482
def resolve(): ''' code here ''' import sys N = int(input()) adjacency_list = [[int(item) for item in input().split()] for _ in range(N)] adjacency_mat = [[0 for _ in range(N)] for _ in range(N)] for i, adjacency in enumerate(adjacency_list): if adjacency[1] != 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,795
s979454273
p02237
u838900850
1585669856
Python
Python3
py
Accepted
20
5668
308
def main(): n = int(input()) e = [[0]*n for _ in range(n)] for i in range(n): m = list(map(int,input().split())) for j in range(2,len(m)): e[m[0]-1][m[j]-1] = 1 for i in range(n): print (' '.join(map(str,e[i]))) if __name__ == '__main__': main()
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,796
s368085110
p02237
u176870835
1585382603
Python
Python3
py
Accepted
20
5672
290
#!/usr/bin/env python3 import sys sys.setrecursionlimit(15000) n = int(sys.stdin.readline()) ret = [] inp = sys.stdin.readlines() G = [[0]*n for _ in range(n)] for i in range(n): v = list(map(int,inp[i].split())) for j in v[2:]: G[v[0]-1][j-1] = 1 print(" ".join(map(str,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,797
s129284945
p02237
u093588014
1584971933
Python
Python3
py
Accepted
20
6380
176
n=int(input()) a=[[0]*n for i in range(n)] for _ in range(n): b=[int(i)-1 for i in input().split()] for i in b[2:]: a[b[0]][i]=1 for i in a: 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,798
s518826996
p02237
u165564808
1584775293
Python
Python3
py
Accepted
20
5604
555
def parse(line): params = line.split(' ') node = params[0] n_node = params[1] nodes = [int(p) for p in params[2:]] return node, n_node, nodes def main(): n = int(input().strip()) for _ in range(n): line = input().strip() _, _, nodes = parse(line) out = '' f...
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,799
s572028620
p02237
u230072054
1584420654
Python
Python3
py
Accepted
30
6448
424
from collections import deque from enum import Enum import sys import math BIG_NUM = 2000000000 MOD = 1000000007 EPS = 0.000000001 V = int(input()) table = [['0']*V for i in range(V)] for loop in range(V): tmp_array = list(map(int,input().split())) node_id = tmp_array[0]-1 for i in range(tmp_array[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,800
s442796950
p02237
u705234550
1584420505
Python
Python3
py
Accepted
20
5680
335
n = int(input()) A = [ [] for i in range(n)] for i in range(n): A[i] = list(map(int, input().split())) B = [[ 0 for i in range(n)] for j in range(n)] for i in range(n): a = A[i][0] j = A[i][1] if j != 0: for k in range(j): b = A[i][k+2] B[a-1][b-1] = 1 for i in range(n): print(" ".join(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,801
s640634285
p02237
u566160059
1584260614
Python
Python3
py
Accepted
20
5604
232
if __name__ == '__main__': n = int(input()) for i in range(n): u, k, *v = map(int, input().split()) a = [0] * n for i_v in v: index_v = i_v -1 a[index_v] = 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,802
s492594085
p02237
u217435805
1584232715
Python
Python3
py
Accepted
20
5676
277
import sys # sys.stdin = open('input.txt') n = int(input()) matrix = [[0]*n for i in range(n)] for i in range(n): u, k, *v = map(int, input().split()) for j in v: matrix[i][j-1] = 1 for line in matrix: line = list(map(str, line)) print(' '.join(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,803
s038353845
p02237
u722578639
1584175946
Python
Python3
py
Accepted
20
6388
349
g = int(input()) v = [[0] * g for _ in range(g)] for i in range(g): inp = list(map(int, input().split())) for j in range(inp[1]): v[inp[0]-1][inp[2+j]-1] = 1 for row in range(g): for col in range(g): if col == g-1: print(v[row][col], end="") else: print(v[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,804
s995388100
p02237
u639594975
1584167439
Python
Python3
py
Accepted
30
6524
429
n = int(input()) mat = [[0] * (n) for _ in range(n)] for _ in range(n): array = list(map(int, input().split())) u = array[0] k = array[1] for i in range(2, len(array)): mat[u - 1][array[i] - 1] = 1 # mat[array[i] - 1][u - 1] = 1 for i in range(n): for j in range(n): if j =...
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,805
s007453029
p02237
u925219592
1583566889
Python
Python3
py
Accepted
20
6388
223
n = int(input()) adj_matrix = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): l = list(map(int, input().split()))[2:] for j in l: adj_matrix[i][j-1] = 1 for l in adj_matrix: print(*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,806
s585837353
p02237
u327242612
1583463740
Python
Python3
py
Accepted
20
5680
515
from sys import stdin input = stdin.readline n = int(input()) M = [['0']*n for _ in range(n)] # 0オリジンの隣接行列、0で初期化しておく for _ in range(n): u, k, *vv = input().split() u = int(u)-1 # 0オリジンにする k = int(k) # kは使わない for v in vv: v = int(v)-1 # 0オリジンにする M[u][v] = '1' #最後に出力するときstr型である必要がある...
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,807
s205142355
p02237
u357050809
1583210260
Python
Python3
py
Accepted
20
5672
306
n = int(input()) adj_list = [ [0]*n for _ in range(n) ] for _ in range(n): lst = list(map(int, input().split())) x = lst[0] - 1 if lst[1] == 0: continue for y in lst[2:]: adj_list[x][y-1] = 1 for r in adj_list: print(" ".join([ str(v) for v in 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,808
s727809848
p02237
u910413188
1583054500
Python
Python3
py
Accepted
30
6384
507
n=int(input()) #隣接リストtableを作る table = [[0 for i in range(n)] for j in range(n)] for _ in range(n): input_ls=list(map(int,input().split())) #頂点と辺の整理 vertex=input_ls[0] edges_count=input_ls[1] edges=input_ls[2:] for k in edges: table[vertex-1][k-1]=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,809
s819220061
p02237
u942532706
1582724221
Python
Python3
py
Accepted
40
7096
375
# -*- coding: utf-8 -*- n = int(input()) adj = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): ls = list(map(int, input().split(" "))) f = ls[0] for i in range(ls[1]): adj[f - 1][ls[2 + i] - 1] = 1 for i in range(n): for j in range(n): print(adj[i][j], end="") if...
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,810
s932362399
p02237
u240839092
1582361173
Python
Python3
py
Accepted
20
5608
315
def convert_adjacency_list_to_matrices(): n = int(input()) for _ in range(n): _, _, *v = map(int, input().split()) s = set(v) ans = list(map(str, [int(i in s) for i in range(1, n+1)])) print(" ".join(ans)) if __name__ == "__main__": convert_adjacency_list_to_matrices()
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,811
s151661234
p02237
u670802622
1582281313
Python
Python3
py
Accepted
20
5636
224
# Graph N = int(input()) G = [[0]*N for i in range(N)] for i in range(N): lst = list(map(int, input().split())) idx = lst[0] for j in range(lst[1]): G[idx-1][lst[2:][j]-1] = 1 print(*G[idx-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,812
s006369627
p02237
u209037521
1581264378
Python
Python3
py
Accepted
20
5672
267
dat = [] n = int(input()) for i in range(n): dat.append([0] * n) for i in range(n): s = list(map(int, input().split())) for j in range(len(s) - 2): dat[i][s[j + 2] - 1] = 1 for i in range(n): l = list(map(str, dat[i])) print(" ".join(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,813
s293700086
p02237
u319394183
1580712778
Python
Python3
py
Accepted
20
5616
329
""" 隣接リストで与えられる有向グラフを,隣接行列で構成しなおす """ n = int(input()) for i in range(n): mat = [0 for _ in range(n)] l = list(map(int, input().split())) deg = l[1] for r in range(deg): index = l[r+2]-1 mat[index] = 1 print(' '.join(map(str, mat)))
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,814
s771324676
p02237
u924675516
1580702755
Python
Python3
py
Accepted
20
5672
491
def main(): n = int(input()) M = [[0] * n for _ in range(n)] for i in range(n): line = input() inputs = [int(x) for x in line.split(' ')] u = inputs.pop(0) u -= 1 # 0 オリジンへ変換 _ = inputs.pop(0) for v in inputs: v -= 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,815
s885004505
p02237
u644946737
1580202050
Python
Python3
py
Accepted
20
5676
217
n = int(input()) g = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): a = list(map(int,input().split())) u = a.pop(0) a.pop(0) for v in a: g[u-1][v-1] = 1 for a in g: 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,816
s565889912
p02237
u647694976
1580112380
Python
Python3
py
Accepted
20
6388
212
n=int(input()) A=[list(map(int,input().split())) for i in range(n)] M=[[0 for i in range(n)] for j in range(n)] for i in range(n): for j in A[i][2:]: M[i][j-1]=1 for i in range(n): print(*M[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,817
s271936532
p02237
u011621222
1579803221
Python
Python3
py
Accepted
20
5604
157
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,818
s718143299
p02237
u079849541
1579762427
Python
Python3
py
Accepted
20
6384
227
n = int(input()) main = [[0] * (n+1) for i in range(n+1)] for i in range(n): a = input().split() for j in range(int(a[1])): main[int(a[0])][int(a[j+2])] = 1 #print(main) for i in range(1,n+1): print(*main[i][1:]) del 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,819
s165914594
p02237
u230220367
1579357978
Python
Python3
py
Accepted
20
5668
334
l = int(input()) rlist = [] for i in range(l): li = list(map(int, input().split())) rlist.append(li[2:]) result = [] for i in range(l): rcell = [0] * l for rl in rlist[i]: rcell[rl-1] = 1 result.append(rcell) for r in result: re = '' for rr in r: re += str(rr) + ' ' 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,820
s502707981
p02237
u617002940
1579093037
Python
Python3
py
Accepted
20
5748
596
N = int(input()) class Matrix: def __init__(self, N): self.M = [[0 for _ in range(N)] for _ in range(N)] def set(self, i, j, val): self.M[i-1][j-1] = val def __repr__(self): str_lines = [] for line in self.M: str_lines.append(' '.join(map(str, 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,821
s704084257
p02237
u194126754
1577426056
Python
Python3
py
Accepted
20
5640
211
n = int(input()) M =[[0]*n for _ in range(n)] for i in range(n): tmp = list(map(int, input().split())) if tmp[1] != 0: for adj in tmp[2:]: M[i][adj-1] = 1 print(*M[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,822
s235631158
p02237
u894062759
1577076140
Python
Python3
py
Accepted
20
6380
411
n = int(input()) adj = [] # adj = [[None] * n for _ in range(n)] ans = [[0] * n for _ in range(n)] for i in range(n): temp = list(map(int, input().split())) if len(temp) > 2: adj.append(temp[2:]) else: adj.append([]) # print(adj) # print(ans) for i in range(n): for j in range(len(adj[...
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,823
s834917768
p02237
u529459816
1576671824
Python
Python3
py
Accepted
30
5668
493
def conv_list(n): adj_matrix = [] for _ in range(n): adj_list = input().split() adj_list = list(map(int, adj_list)) adj_row = [0] * n if adj_list[1] > 0: for i in adj_list[2:]: adj_row[i - 1] = 1 adj_matrix.append(adj_row) return adj_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,824
s908157400
p02237
u064444227
1576462369
Python
Python3
py
Accepted
20
5684
204
n=int(input()) ans=[] for i in range(n): u,k,*v=list(map(int,input().split())) s = [0 for i in range(n)] for j in v: s[j-1]=1 ans.append(s) for i in ans: I=map(str,i) print(" ".join(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,825
s132701194
p02237
u123563150
1576218118
Python
Python3
py
Accepted
20
6388
188
n=int(input()) c=[[0 for _ in range(n)]for _ in range(n)] for i in range(n): a=list(map(int,input().split())) for j in range(2,len(a)): c[i][a[j]-1]=1 for i in range(n): print(*c[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,826
s849264493
p02237
u794140916
1575942629
Python
Python3
py
Accepted
30
6388
311
n = int(input()) m = [[0 for i in range(n + 1)] for j in range(n + 1)] for i in range(n): nums=list(map(int,input().split())) for j in range(nums[1]): m[i + 1][nums[j + 2]] = 1 for i in range(n): for j in range(n-1): print(m[i + 1][j + 1], end = " ") print(m[i + 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,827
s619298233
p02237
u958870136
1575433519
Python
Python3
py
Accepted
20
5676
244
n = int(input()) v_matrix = [[0 for j in range(n+1)] for i in range(n+1)] for i in range(n): u, k, *v = map(int, input().split()) for vi in v: v_matrix[u][vi] = 1 for row in v_matrix[1:]: print(" ".join(map(str, row[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,828
s285035874
p02237
u504636463
1575285744
Python
Python3
py
Accepted
20
5680
384
if __name__ == '__main__': n = int(input()) graph = [[0 for i in range(n)] for _ in range(n)] for i in range(n): datas = [int(num) for num in input().split(' ')] if datas[1] > 0: for j in datas[2:]: graph[datas[0] - 1][j - 1] = 1 for row in graph: pri...
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,829
s607327972
p02237
u578043650
1574612337
Python
Python3
py
Accepted
20
6392
329
num = int(input()) mat = [[0 for i in range(num)] for j in range(num)] for i in range(num): arr = list(map(int,input().split())) if arr[1] >= 1: for j in range(len(arr)-2): m = arr[j+2] mat[i][m-1] += 1 else: pass for i in range(num): 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,830
s492060772
p02237
u793120772
1574154657
Python
Python3
py
Accepted
20
6388
242
n=int(input()) A=[[0 for i in range(n)] for j in range(n)] for i in range(n): point=[int(j) for j in input().split()] if point[1]>0: for k in point[2:]: if k:A[i][k-1]=1 for i in A: 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,831
s810430544
p02237
u608189632
1573994814
Python
Python3
py
Accepted
20
5680
334
n = int(input()) M = [[0 for i in range(n)] for j in range(n)] for i in range(n): _ = list(map(int, input().split())) u = _[0] - 1 # 0オリジンに変換 degree = _[1] for j in range(degree): v = _[j+2] - 1 # 0オリジンに変換 M[u][v] = 1 for row in M: 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,832
s224800495
p02237
u439083584
1573199166
Python
Python3
py
Accepted
20
6388
178
n=int(input()) ans=[[0]*n for _ in range(n)] for _ in range(n): u,k,*V=map(int,input().split()) for v in V: ans[u-1][v-1]=1 for i in range(n): print(*ans[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,833
s063729590
p02237
u410881919
1573123786
Python
Python3
py
Accepted
30
5680
259
absN = int(input()) M = [[0 for _ in range(absN)] for _ in range(absN)] for _ in range(absN): cmd = list(map(int, input().split(" "))) for i in range(cmd[1]): M[cmd[0]-1][cmd[i+2]-1] = 1 for x in M: x =map(str, x) print(" ".join(x))
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,834
s593351517
p02237
u806005289
1572844873
Python
Python3
py
Accepted
20
5676
290
n = int(input()) answerL = [] for i in range(n): inputL = input().split() newL = [0]*n k = int(inputL[1]) for j in range(k): target = int(inputL[1+j+1]) newL[target-1] = 1 answerL.append(newL) for ans in answerL: print(' '.join(list(map(str, ans))))
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,835
s355685374
p02237
u137240270
1572308913
Python
Python3
py
Accepted
20
5684
339
def main(): n = int(input()) graph = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): u, k, *v_s = map(int, input().split(' ')) for j in range(k): graph[u-1][v_s[j-1]-1] = 1 for row in graph: print(' '.join(map(str, row))) 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,836
s208147910
p02237
u639928232
1571927835
Python
Python3
py
Accepted
20
6384
316
#!/usr/bin/env python3 import sys input = lambda: sys.stdin.readline()[:-1] sys.setrecursionlimit(10**8) n=int(input()) G=[[0]*n for i in range(n)] for i in range(n): inp=tuple(map(int,input().split())) now=inp[0] for j in range(2,inp[1]+2): G[now-1][inp[j]-1]=1 for g in G: print(*g)
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,837
s403667438
p02237
u525329683
1571757645
Python
Python3
py
Accepted
20
5608
476
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/11/ALDS1_11_A # やるだけ # 有向成分を読み込むたびにノード番号に対応する表に書き込んでいけばよい N = int(input()) for _ in range(N): out_ls = [0]*N tmp = list(map(int, input().split())) # id = tmp[0]-1 #idは順番通り与えられるので実はこれもいらない if tmp[1] != 0: for adj in tmp[2:]: o...
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,838
s084049356
p02237
u909811933
1571756641
Python
Python3
py
Accepted
20
6384
193
n = int(input()) a=[[0 for i in range(n)] for j in range(n)] for i in range(n): info = [int(x) for x in input().split()] for j in info[2:]: a[i][j-1]=1 for v in a: 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,839
s116545863
p02237
u778781355
1571020555
Python
Python3
py
Accepted
20
6384
291
if __name__ == "__main__": n = int(input()) A = [[0 for j in range(n)] for i in range(n)] for _ in range(n): command = list(map(int, input().split())) u = command[0] k = command[1] for l in range(k): v = command[l + 2] A[u - 1][v - 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,840
s790101408
p02237
u476418873
1570337071
Python
Python3
py
Accepted
20
5600
195
n = int(input()) dic = {} for _ in range(n): datum = list(map(int, input().split())) status = ["0"]*n for i in datum[2:]: status[i-1] = "1" print(" ".join(status))
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,841
s553156664
p02237
u367619546
1570107189
Python
Python3
py
Accepted
20
5676
331
#ALDS1_11_A Graph import sys n = int(input()) A = [[0] * n for _ in range(n)] for i in range(n): Adj = list(map(int, sys.stdin.readline().strip().split())) if Adj[1] >= 1: v = Adj[2:] for j in v: A[i][j - 1] = 1 # A[j - 1][i - 1] = 1 for i in A: print(' '.join(map(...
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,842
s317238448
p02237
u153665391
1569713899
Python
Python3
py
Accepted
20
5680
234
N = int(input()) L = [list(map(int, input().split())) for i in range(N)] adj = [[0 for i in range(N)] for j in range(N)] for i in range(N): for node in L[i][2:]: adj[i][node-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,843
s790980247
p02237
u803862921
1569500341
Python
Python3
py
Accepted
20
6384
218
num = int(input()) L = [[ 0 for x in range(num)] for y in range(num)] for _ in range(num): c,k,*v = [int(x)-1 for x in input().split()] for i in v: L[c][i] = 1 for i in range(num): print( *L[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,844
s409879352
p02237
u134521115
1569239886
Python
Python3
py
Accepted
20
5680
383
import sys input = sys.stdin.readline def main(): n = int(input()) G = [[0]*n for _ in range(n)] for _ in range(n): a = list(map(int, input().split())) u = a[0] - 1 k = a[1] for i in range(k): v = a[2+i] - 1 G[u][v] = 1 for g 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,845
s367238427
p02237
u183700122
1568627695
Python
Python3
py
Accepted
20
5600
171
n = int(input()) for i in range(n): nums = list(map(int, input().split())) ans = ['0'] * n for j in nums[2:]: ans[j-1] = '1' print(' '.join(ans))
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,846
s802699350
p02237
u482227082
1568205518
Python
Python3
py
Accepted
20
6388
350
import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(input()) G = [[0] * n for _ in range(n)] for i in range(n): u, k, *v = map(int, input().split()) for j in range(k): G[u-1][v[j]-1] = 1 for i in range(n): print(*G[i]) if __name...
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,847
s838402438
p02237
u631142478
1566492444
Python
Python3
py
Accepted
20
5668
297
def main(): n = int(input()) m = [[0] * n for _ in range(n)] for _ in range(n): u, k, *v = map(int, input().split()) for i in range(k): m[u - 1][v[i] - 1] = 1 for row in m: print(' '.join(map(str, row))) if __name__ == '__main__': main()
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,848
s262862874
p02237
u784856415
1566392701
Python
Python3
py
Accepted
20
6436
524
#import pysnooper #import os,re,sys,operator,math,heapq,string #from collections import Counter,deque #from operator import itemgetter from itertools import accumulate,combinations,groupby,combinations_with_replacement from sys import stdin,setrecursionlimit #from copy import deepcopy setrecursionlimit(10**6) n=int(st...
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,849
s212804792
p02237
u221424603
1566365993
Python
Python3
py
Accepted
20
5668
238
n=int(input()) G=[[0 for i in range(n)] for j in range(n)] for i in range(n): u=list(map(int,input().split())) for j in range(2,len(u)): G[i][u[j]-1]=1 G=[' '.join(map(str,G[i])) for i in range(n)] print('\n'.join(G))
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,850
s246657418
p02237
u817810878
1564989946
Python
Python3
py
Accepted
30
5668
381
if __name__ == "__main__": num_vertices = int(input()) adj_matrix = [[0] * num_vertices for i in range(num_vertices)] for _ in range(num_vertices): vertex, _, *adjs = map(lambda x: int(x), input().split()) for adj in adjs: adj_matrix[vertex -1][adj - 1] = 1 for row in adj_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,851
s500540025
p02237
u470586273
1564825909
Python
Python3
py
Accepted
20
5668
228
n=int(input()) a=[[0]*n for _ in range(n)] u=0 k=0 for i in range(n): ukv=list(map(int,input().split())) for j in range(2,2+ukv[1]): a[ukv[0]-1][ukv[j]-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,852
s207999153
p02237
u453734454
1564744062
Python
Python3
py
Accepted
20
5680
207
n = int(input()) m = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): u, k, *v = map(int, input().split()) for j in v: m[u-1][j-1] = 1 for i in range(n): print(" ".join(map(str,m[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,853
s553988807
p02237
u182175955
1563506235
Python
Python3
py
Accepted
20
6392
353
n=int(input()) V=[] for i in range(n): temp=input().split( ) l=len(temp) v=[] for j in range(l): v.append(int(temp[j])) V.append(v) A=[[0 for i in range(n)] for j in range(n)] for i in range(n): k=V[i][1] if k>0: for j in range(k): A[V[i][0]-1][V[i][j+2]-1]=1 for ...
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,854
s995550224
p02237
u420573886
1562826446
Python
Python3
py
Accepted
20
5604
190
n = int(input()) l = [] pad = 0 for i in range(n): m = [0]*n s = list(map(int,input().split())) if s[1] != 0: for j in s[2:]: m[j-1] = 1 print(*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,855
s177283211
p02237
u357267874
1562372897
Python
Python3
py
Accepted
20
5668
212
n = int(input()) A = [[0] * n for _ in range(n)] for _ in range(n): u, k, *v = list(map(int, input().split())) for j in v: A[u-1][j-1] = 1 for row in A: print(' '.join(list(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,856
s649123324
p02237
u902579831
1561550492
Python
Python3
py
Accepted
20
6384
211
n = int(input()) matrix = [[0] * n for _ in range(n)] for i in range(n): u, k, *V = map(int, input().split()) for v in V: v -= 1 matrix[i][v] = 1 for row in matrix: 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,857
s976692095
p02237
u715278210
1561460659
Python
Python3
py
Accepted
20
5684
233
N = int(input()) G = [[0 for i in range(N)] for j in range(N)] for i in range(N): ls = list(map(int,input().split())) u = ls[0] - 1 for v in ls[2:]: G[u][v-1] = 1 for row in G: 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,858
s230127001
p02237
u353547847
1561453226
Python
Python3
py
Accepted
20
5676
254
N = int(input()) P = [[0 for _ in range(N)] for _ in range(N)] for i in range(N): u,k,*varray = map(int,input().split()) # u,k は数, varray は配列 for v in varray: P[u-1][v-1] = 1 for j in P: print(" ".join(map(str,j)))
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,859
s541345464
p02237
u010611609
1561444126
Python
Python3
py
Accepted
20
5668
239
n = int(input()) matrix = [[0] * n for _ in range(n)] for _ in range(n): line = list(map(int, input().split())) u = line[0] for v in line[2:]: matrix[u-1][v-1] = 1 for row in matrix: 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,860
s750742687
p02237
u026821956
1561388749
Python
Python3
py
Accepted
20
5668
239
n = int(input()) G = [] for i in range(n): T = [0]*n G.append(T) for i in range(n): L = list(map(int,input().split())) for j in range(2,len(L)): G[i][L[j]-1] += 1 for i in range(n): print(' '.join(map(str,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,861
s764132068
p02237
u698762975
1561371746
Python
Python3
py
Accepted
20
5604
264
n=int(input()) l=[] for i in range(n): l1=list(map(int,input().split())) l2=[] if l1[1]==0: l2=["0" for j in range(n)] else: for j in range(n): if j+1 in l1[2:]: l2.append("1") else: l2.append("0") print(" ".join(l2))
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,862
s169013018
p02237
u528682978
1561371664
Python
Python3
py
Accepted
20
5676
266
n = int(input()) matrix = [[0]*n for i in range(n)] for _ in range(n): lis = list(map(int,input().split())) if lis[1] > 0: for i in lis[2:]: matrix[lis[0]-1][i-1] = 1 for lis in matrix: x = list(map(str,lis)) print(" ".join(x))
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,863
s586870529
p02237
u772853944
1561370788
Python
Python3
py
Accepted
20
5672
203
n=int(input()) m=[[0]*n for i in range(n)] for i in range(n): tmp=list(map(int,input().split())) for j in tmp[2:]: m[i][j-1]=1 for i in range(n): print(" ".join(list(map(str,m[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,864
s685214150
p02237
u481944101
1561370760
Python
Python3
py
Accepted
20
6384
166
n=int(input()) a=[[0]*n for _ in range(n)] for _ in range(n): u,k,*v=map(int,input().split()) for j in v: a[u-1][j-1]=1 for row in a: 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,865
s702993646
p02237
u135880652
1561290504
Python
Python3
py
Accepted
30
7096
361
n = int(input()) results = [[0] * n for i in range(n)] for i in range(n): arr = list(map(int, input().split())) for j in range(arr[1]): results[i][arr[j+2]-1] = 1 for ret in results: for i in range(len(ret)): if i == len(ret)-1: print(ret[i], end='') else: ...
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,866
s534630977
p02237
u653744760
1560841464
Python
Python3
py
Accepted
20
6380
301
n=int(input()) matrix=[] for i in range(n): matrix.append([0]*n) for i in range(n): listi=list(map(int,input().split())) for j in range(listi[1]): matrix[i][listi[j+2]-1]=1 for i in range(n): for j in range(n-1): print(matrix[i][j],end=" ") print(matrix[i][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,867
s434574348
p02237
u208260150
1560344048
Python
Python3
py
Accepted
30
6384
311
n=int(input()) da=[[0 for i in range(n)] for i in range(n)] for i in range(n): se=list(map(int,input().split())) for j in se[2:]: da[i][j-1]=1 for i in range(n): for j in range(n): if j==n-1: print(da[i][j]) else: print(da[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,868
s641326957
p02237
u350698365
1558064080
Python
Python3
py
Accepted
20
5672
360
N = int(input()) T = [[0] * (N+1) for _ in range(N+1)] for i in range(N): tmp = [int(ele) for ele in input().split()] from_ = tmp[0] for j in tmp[2:]: T[from_][j] = 1 def main(): for i in T[1:]: ans = "" for j in i[1:]: ans += str(j) + " " print(ans[:-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,869
s649428313
p02237
u454636644
1557415756
Python
Python3
py
Accepted
20
5680
369
import sys input = sys.stdin.readline n = int(input()) adj_list = [[0]*n for _ in range(n)] for _ in range(n): input_list = list(map(int, input().split())) u = input_list[0] - 1 e_num = input_list[1] if e_num > 0: for i in range(e_num): adj_list[u][input_list[i+2] - 1] = 1 for adj ...
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,870
s510248392
p02237
u182167513
1557126113
Python
Python3
py
Accepted
20
6384
431
n = int(input()) #頂点数 matrix = [[0]*n for i in range(n)] for i in range(n): adj_list = list(map(int,input().split())) for j in adj_list[2:]: #3番目からの隣接ノードを取得する matrix[i][j-1] = 1 #隣接ノードを成分を1に変更する for i in range(n): for j in range(n): if j != n-1: print(matrix[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,871
s535051319
p02237
u805716376
1556965142
Python
Python3
py
Accepted
20
6384
183
n = int(input()) adj = [[0]*n for i in range(n)] for i in range(n): a, *b = input().split()[1:] for j in b: adj[i][int(j)-1] = 1 for i in range(n): print(*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,872
s068386715
p02237
u967553879
1554962861
Python
Python3
py
Accepted
20
5636
201
n = int(input()) ans = [[0 for i in range(n)] for j in range(n)] for i in range(n): n1, num, *cl = list(map(int, input().split())) for n2 in cl: ans[n1-1][n2-1] = 1 print(*ans[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,873
s483506177
p02237
u799595944
1554932797
Python
Python3
py
Accepted
20
5672
227
n = int(input()) ans = [[0]*n for i in range(n)] for i in range(n): inta = list(map(int,input().split(" "))) for j in inta[2:2+inta[1]]: ans[inta[0]-1][j-1] = 1 for i in ans: print(" ".join(map(str,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,874
s725240178
p02237
u062898953
1554179533
Python
Python3
py
Accepted
20
5600
183
n = int(input()) for i in range(n): u, k, *v, = map(int, input().split()) r = [] for j in range(1, n+1): r.append(str(1 if j in v else 0)) 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,875
s279785786
p02237
u065504661
1553949770
Python
Python3
py
Accepted
20
5664
409
n = int(input()) adj = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): l = list(map(int, input().split())) if l[1] == 0: print(' '.join(list(map(str, adj[i])))) # continue else: for j in range(2,len(l)): adj[l[0]-1][l[j]-1] = 1 print(' '.join(list(map...
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,876
s818646389
p02237
u597769560
1553240747
Python
Python3
py
Accepted
20
5692
357
# -*- coding: utf-8 -*- """ Created on Fri Mar 22 16:34:05 2019 @author: Yamazaki Kenichi """ n = int(input()) A = [list(map(int,input().split())) for i in range(n)] T = [[0 for i in range(n)] for i in range(n)] for c in A: if c[1] != 0: for i in range(c[1]): T[c[0]-1][c[i+2]-1] = 1 for c 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,877
s473803343
p02237
u452220492
1552795837
Python
Python3
py
Accepted
20
5680
321
n = int(input()) ans = list() for i in range(n): tmp = list() for j in range(n): tmp.append(0) ans.append(tmp) for i in range(n): l = [int(i) for i in input().split()] for li in l[2:]: # print(i, li) ans[i][li - 1] = 1 for i in ans: print(" ".join([str(x) for x in 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,878
s983975784
p02237
u276288047
1552011954
Python
Python3
py
Accepted
40
7092
387
# coding: utf-8 N = int(input().rstrip()) A = [[0 for _ in range(N)] for _ in range(N)] for i in range(N): line = [int(i) for i in input().rstrip().split()] for j in range(line[1]): A[line[0]-1][line[j+2]-1] = 1 for i in range(N): for j in range(N): print(A[i][j],end="") if j == 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,879
s146233779
p02237
u415714413
1550811436
Python
Python3
py
Accepted
30
6144
378
import sys readline = sys.stdin.readline write = sys.stdout.write n = int(input()) G = [[0 for i in range(n+1)] for j in range(n+1)] for i in range(n): temp = list(map(int, readline().split())) for j in range(temp[1]): G[temp[0]][temp[j+2]] = 1 for i in range(1, n+1): for j in range(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,880
s127063163
p02237
u925817380
1550620447
Python
Python3
py
Accepted
20
5668
452
V = int(input()) # 这个就不行。涉及深浅复制? # table = [['0']*V]*V table = [['0']*V for _ in range(V)] for _ in range(V): # split 只能用于string # map returns a map object temp = list(map(int,input().split())) if len(temp) >= 2: for nei in temp[2:]: # print(temp[0]-1,nei-1) table[temp[...
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,881