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
s131914705
p02237
u957021183
1504243931
Python
Python3
py
Accepted
20
7768
445
# Aizu Problem ALDS_1_10_B: Graph # import sys, math, os # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") n = int(input()) G = [[0 for _ in range(n)] for __ in range(n)] for row in range(n): inp = [int(_) for _ in input().split()] a = inp[0] 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,682
s255401776
p02237
u659034691
1504639452
Python
Python3
py
Accepted
20
7852
438
# your code goes here #graph #????????????????¨?????????¨ n=int(input()) L=[] for i in range(n): L.append([]) for j in range(n): L[i].append("0") #rint(L) for i in range(n): v=[int(i) for i in input().split()] # print(v) for j in range(2,2+v[1]): L[v[0]-1][v[j]-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,683
s677680318
p02237
u193453446
1504760536
Python
Python3
py
Accepted
20
7792
346
def main(): num = int(input()) T = [[0] * num for i in range(num)] for n in range(num): a = list(map(int,input().split())) u = a[0] - 1 if a[1] > 0: for i in a[2:]: T[u][i-1] = 1 for i in range(num): print(" ".join(map(str,T[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,684
s812654609
p02237
u796784914
1505538935
Python
Python
py
Accepted
10
6468
395
def main(): n = input() Adj = [[0]*n for m in xrange(n)] for i in xrange(n): a = map(int,raw_input().split()) for j in xrange(a[1]): Adj[i][a[2:][j]-1] = 1 for i in xrange(n): for j in xrange(n): if j == n-1: print Adj[i][j] el...
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,685
s480740531
p02237
u368364462
1505615224
Python
Python
py
Accepted
30
6420
271
if __name__ == '__main__': N = input() m = [[0] * N for i in range(N)] for i in range(N): v = map(int, raw_input().split()) for j in v[2:]: m[i][j-1] = 1 for row in m: for i in row: print i, 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,686
s838725633
p02237
u236679854
1506901657
Python
Python3
py
Accepted
20
7700
255
n = int(input()) for i in range(n): u, k, *v = map(int, input().split()) row = "" for j in range(1, n + 1): if j in v: row += "1" else: row += "0" if j != n: row += " " 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,687
s055636025
p02237
u146816547
1507224070
Python
Python
py
Accepted
10
6464
296
n = int(raw_input()) G = [[0 for i in xrange(n)] for j in xrange(n)] for i in xrange(n): data = map(int, raw_input().split()) u = data[0]-1 k = data[1] for j in xrange(k): v = data[j+2]-1 G[u][v] = 1 for i in xrange(n): print " ".join([str(x) for x in 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,688
s484239604
p02237
u792145349
1507341117
Python
Python3
py
Accepted
60
8560
423
# ??\??????????????? n = int(input()) data = [list(map(int,input().split())) for i in range(n)] # N*N?????£??\??????????????°????????? graph_table = [[0]*n for i in range(n)] # ??£??\??????????????£??\??????????????? for d in data: node_id = d[0] num_of_e = d[1] for e in d[2:]:#???????????????????????????...
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,689
s307091437
p02237
u756958775
1507392000
Python
Python3
py
Accepted
30
7796
310
n = int(input()) A = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): tmp_u = list(map(int, input().split())) vs = tmp_u[2:] for v in vs: A[tmp_u[0]-1][v-1] = 1 for i in range(n): tmp_A = A[i] tmp_A = map(str, tmp_A) tmp_A = ' '.join(tmp_A) print(tmp_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,690
s591475624
p02237
u798803522
1509546931
Python
Python3
py
Accepted
20
8440
260
v_num = int(input()) adjacent = [[0 for n in range(v_num)] for m in range(v_num)] for _ in range(v_num): inp = [int(n) for n in input().split(" ")] for i in inp[2:]: adjacent[inp[0] - 1][i - 1] = 1 for i in range(v_num): print(*adjacent[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,691
s730479629
p02237
u024715419
1510205493
Python
Python3
py
Accepted
20
7784
235
n = int(input()) a = [[0 for i in range(n)] for j in range(n)] for i in range(n): inp = list(map(int, input().split())) u = inp[0] k = inp[1] for j in range(k): a[u - 1][inp[2 + j] - 1] = 1 print(*a[u - 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,692
s180028652
p02237
u856963614
1511176114
Python
Python3
py
Accepted
60
8492
339
n=int(input()) adj=[] for i in range(n): adj.append(list(map(int, input().split()))) a=[[0 for i2 in range(n)]for i1 in range(n)] for i in range(n): for j in range(adj[i][1]): a[i][adj[i][j+2]-1]=1 for j in range(n): if j ==n-1: print(a[i][j]) else: 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,693
s949978200
p02237
u424457654
1511858635
Python
Python3
py
Accepted
20
5640
227
n = int(input()) a = [[0 for i in range(n)] for j in range(n)] for i in range(n): v = list(map(int, input().split())) u = v[0] k = v[1] for j in range(k): a[u - 1][v[2 + j] - 1] = 1 print(*a[u - 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,694
s822362728
p02237
u626266743
1511868227
Python
Python3
py
Accepted
20
6388
196
n = int(input()) M = [[0] * n for i in range (n)] for i in range(n): u = list(map(int, input().split())) v = u[0] for j in u[2:]: M[v - 1][j - 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,695
s791541675
p02237
u845643816
1511919583
Python
Python3
py
Accepted
20
6380
228
n = int(input()) a = [[0]*n for i in range(n)] for i in range(n): v = list(map(int, input().split())) u = v[0] k = v[1] for j in range(k): a[u - 1][v[2 + j] - 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,696
s594737321
p02237
u845643816
1512123402
Python
Python3
py
Accepted
20
6380
229
n = int(input()) a = [[0]*n for i in range(n)] for i in range(n): v = list(map(int, input().split())) u, k = v[0], v[1] for j in range(v[1]): a[u - 1][v[2 + j] - 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,697
s028316859
p02237
u845643816
1512124060
Python
Python3
py
Accepted
20
6384
199
n = int(input()) a = [[0]*n for i in range(n)] for i in range(n): v = list(map(int, input().split())) u = v[0] - 1 for j in v[2:]: a[u][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,698
s035329247
p02237
u845643816
1512127304
Python
Python3
py
Accepted
20
5644
188
n = int(input()) a = [[0]*n for i in range(n)] for i in range(n): v = list(map(int, input().split())) u = v[0] - 1 for j in v[2:]: a[u][j - 1] = 1 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,699
s148184714
p02237
u185486509
1514700915
Python
Python3
py
Accepted
20
5608
133
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,700
s338525396
p02237
u650712316
1517484389
Python
Python3
py
Accepted
20
5684
272
# coding: UTF-8 n = int(input()) Ans =[ [0 for i in range(n)] for j in range(n)] for l in range(n): raw = list(map(int,input().split())) i = raw[0] d = raw[1] for m in range(2,d+2): Ans[i-1][raw[m]-1] = 1 for i in range(n): print(" ".join(map(str,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,701
s350833584
p02237
u662418022
1517916116
Python
Python3
py
Accepted
30
5688
370
# -*- coding: utf-8 -*- if __name__ == '__main__': n = int(input()) M = [[0 for i in range(n)] for j in range(n)] for _ in range(n): l = list(map(int, input().split(" "))) u = l[0] k = l[1] if k != 0: for v in l[2:]: M[u-1][v-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,702
s880570537
p02237
u426534722
1518966398
Python
Python3
py
Accepted
20
6380
186
n = int(input()) MAP = [[0] * n for _ in range(n)] for i in range(n): u, k, *v = map(int, input().split()) for j in v: MAP[u - 1][j - 1] = 1 for m in MAP: 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,703
s048058394
p02237
u869924057
1519299119
Python
Python3
py
Accepted
20
5612
294
n = int(input()) Adj = [0 for i in range(n)] for i in range(n): row = list(map(int, input().split(' '))) Adj[row[0] - 1] = row for adj in Adj: k = adj[1] E = adj[2:2+k] row = [0 for i in range(n)] for i in E: row[i - 1] = 1 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,704
s161445719
p02237
u869924057
1519300841
Python
Python3
py
Accepted
20
5612
274
n = int(input()) Adj = [0 for i in range(n)] for i in range(n): row = list(map(int, input().split(' '))) Adj[row[0] - 1] = row for adj in Adj: row = [0 for i in range(n)] for i in adj[2:2+adj[1]]: row[i - 1] = 1 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,705
s038582031
p02237
u117140447
1519555364
Python
Python3
py
Accepted
20
6460
1,074
import sys data_list = [] for line in sys.stdin: data_list.append(line.split()) class Node(): def __init__(self, name, transaction_list = None): self.transaction_list = transaction_list or [] def add_node(self, node): self.transaction_list.append(node) def convert_adjencentList_to_adjencentM...
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,706
s259879488
p02237
u150984829
1519960745
Python
Python3
py
Accepted
20
6380
148
N=int(input()) M=[[0]*N for _ in[0]*N] for e in[list(map(int,input().split()))for _ in[0]*N]: for v in e[2:]:M[e[0]-1][v-1]=1 for r in M:print(*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,707
s327717324
p02237
u150984829
1519960823
Python
Python3
py
Accepted
20
5604
94
N=int(input()) for _ in[0]*N: r=[0]*N for i in input().split()[2:]:r[int(i)-1]=1 print(*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,708
s666219413
p02237
u912143677
1522210904
Python
Python3
py
Accepted
20
6392
225
n = int(input()) g = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): a = list(map(int, input().split())) for j in range(a[1]): g[a[0] - 1][a[j + 2] - 1] = 1 for i in range(n): 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,709
s850665435
p02237
u126478680
1525376199
Python
Python3
py
Accepted
20
5676
269
n = int(input()) A = [[0 for j in range(n)] for i in range(n)] for i in range(n): arr = list(map(int, input().split(' '))) u, k, v = arr[0], arr[1], arr[2:] for j in range(k): A[u-1][v[j]-1] = 1 for li in A: print(' '.join(list(map(str, li))))
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,710
s163382640
p02237
u138546245
1525850018
Python
Python3
py
Accepted
20
5688
862
class AdjacentGraph: """Implementation adjacency-list Graph. Beware ids are between 1 and size. """ def __init__(self, size): self.size = size self._nodes = [[0] * (size+1) for _ in range(size+1)] def set_adj_node(self, id_, adj_id): self._nodes[id_][adj_id] = 1 def __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,711
s219069771
p02237
u089116225
1528622415
Python
Python3
py
Accepted
20
5680
269
n = int(input()) m = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): tmp = [int(x) for x in input().split()] u = tmp[0] k = tmp[1] l = tmp[2:] for x in l: m[u-1][x-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,712
s018725148
p02237
u404682284
1528646535
Python
Python3
py
Accepted
20
5616
298
import sys n = int(input()) input_lines = [[int(i) for i in lines.split()] for lines in sys.stdin.read().splitlines()] for i in range(n): out_list = ['0'] * n m = len(input_lines[i]) for j in range(m-1, 1, -1): out_list[input_lines[i][j]-1] = '1' print(' '.join(out_list))
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,713
s989707506
p02237
u088372268
1529238747
Python
Python3
py
Accepted
30
5680
359
def main(): n = int(input()) m = [[0 for j in range(n+1)] for i in range(n+1)] for i in range(n): d = list(map(int, input().split())) for j in range(2, len(d)): m[d[0]][d[j]] = 1 for i in range(1, n+1): print(" ".join([str(m[i][j]) for j in range(1, len(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,714
s249738554
p02237
u896240461
1529466201
Python
Python3
py
Accepted
20
6376
285
n = int(input()) adm = [] for i in range(n): x = list(map(int,input().split())) tmp = [0]*n if x[1] == 0: adm.append(tmp) else: a = x[2:] for j in a: tmp[j-1] = 1 adm.append(tmp) for i in range(len(adm)): print(*adm[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,715
s530892444
p02237
u564105430
1529466267
Python
Python3
py
Accepted
20
6392
278
#16D8103010K Ko Okasaki #ALDS11a Al=[] n=int(input()) for i in range(n): a=list(map(int,input().split())) Al.append(a[2:]) Am=[[0 for j in range(n)]for i in range(n)] for i in range(n): for k in Al[i]: Am[i][k-1]=1 for i in range(n): print(*Am[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,716
s428193157
p02237
u848218390
1529479915
Python
Python3
py
Accepted
20
6380
554
class Node: def __init__(self, num, deg, neib): self.num = num self.deg = deg self.neib = neib dnum = int(input()) N = [] for i in range(dnum): data = input().split() u = int(data[0]) k = int(data[1]) if k > 0: v = list(map(int, data[2:])) node = Node(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,717
s562944376
p02237
u408444038
1529481076
Python
Python3
py
Accepted
20
6392
229
n = int(input()) G = [[0 for i in range(n)] for j in range(n)] for i in range(n): S = list(map(int, input().split())) tmp_n = S[1] for j in range(tmp_n): G[i][S[j+2]-1] = 1 for i in range(n): 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,718
s013499847
p02237
u564464686
1529481267
Python
Python3
py
Accepted
30
6384
360
n=int(input()) G=[[0 for i in range(n)]for j in range(n)] u=[0 for i in range(n)] for i in range(n): A=input().split() u[i]=int(A[0]) k=int(A[1]) for j in range(k): x=int(A[j+2])-1 G[i][x]=1 for i in range(n): for j in range(n): if j<n-1: print(G[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,719
s491958122
p02237
u826549974
1529481669
Python
Python3
py
Accepted
30
7096
339
n = int(input()) B = [[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(A[1]): B[A[0]-1][A[j+2]-1] = 1 for i in range(n): for j in range(n): print(B[i][j],end="") if(j == n-1): print() 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,720
s831786172
p02237
u064320529
1529481768
Python
Python3
py
Accepted
40
7092
347
n=int(input()) g=[[0 for i in range(n)]for j in range(n)] for i in range(n): s=input() l=s.split() for i in range(len(l)): l[i]=int(l[i]) for i in l[2:]: g[l[0]-1][i-1]+=1 for i in range(n): for j in range(n): print(g[i][j],end="") if j!=len(g[i])-1: 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,721
s661255232
p02237
u196653484
1529481958
Python
Python3
py
Accepted
20
6384
316
def main(): n=int(input()) v=[] array=[] for i in range(n): zero=[0 for i in range(n)] a=list(map(int,input().split())) a=a[2:] for j in a: zero[j-1]=1 array.append(zero) for i in array: print(*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,722
s619581654
p02237
u411881271
1529482381
Python
Python3
py
Accepted
30
6392
303
n = int(input()) A = [[0 for i in range(n)] for j in range(n)] for i in range(n): B = input().split() if B[1]!=0: for j in range(int(B[1])): #B[2+j] A[i][int(B[2+j])-1] = 1 for i in range(n): for j in range(n): if j!=n-1: print(A[i][j], end=" ") else: print(A[i][j], end="\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,723
s075511599
p02237
u684325232
1529482729
Python
Python3
py
Accepted
20
6392
260
n=int(input()) l=[[0 for i in range(n)] for j in range(n)]##静的確保 for i in range(n): p=[int(x) for x in input().split()] for j in range(n): if j+1 in p[2:]: l[i][j]=1 for i in range(n): 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,724
s320210913
p02237
u733945366
1529482807
Python
Python3
py
Accepted
20
6392
369
n=int(input()); G=[[0 for i in range(n)]for j in range(n)] for i in range(n): list=[int(m) for m in input().split()] u=list[0] k=list[1] for j in range(2,len(list)): v=list[j] G[u-1][v-1]=1 for i in range(n): for j in range(n): if j!=n-1: print(G[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,725
s537241147
p02237
u217703215
1529484184
Python
Python3
py
Accepted
20
6384
353
n=int(input()) a=[[0 for i in range(n)]for j in range(n)] for i in range(n): v=list(input().split()) for j in range(len(v)): v[j]=int(v[j]) x=2 for k in range(v[1]): a[i][v[x+k]-1]=1 for i in range(n): for j in range(n): if j!=n-1: print(a[i][j],end=" ") 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,726
s546117321
p02237
u055885332
1529484629
Python
Python3
py
Accepted
30
6384
403
#16D8101014F KurumeRyunosuke 2018/6/20 #import numpy as np n=int(input()) #ls=np.zeros((n,n)) ls=[[0 for i in range(n)]for j in range(n)] for i in range(n): tmp=input().split() for j in range(int(tmp[1])): #print("*") ls[i][int(tmp[j+2])-1]=1 for i in range(n): for j in range(n): 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,727
s210989351
p02237
u728137020
1529484896
Python
Python3
py
Accepted
20
6384
213
N= int(input()) b=[[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(a[1]): b[i][a[2+j]-1]=1 for i in range(N): print(*b[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,728
s275765139
p02237
u836567931
1529486207
Python
Python
py
Accepted
10
4708
471
n=int(input()) arr = [[0 for i in range(n)] for j in range(n)] #for i in arr: #print(' '.join(map(str, i))) #print(arr) for i in range(0,n): l=raw_input().split() if(int(l[1])>=1): x=int(l[0]) y=int(l[1]) p=len(l) d=0 while(2+d<p): z=int(l[2+d]) ...
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,729
s806435420
p02237
u772417059
1529678217
Python
Python3
py
Accepted
30
6388
212
n=int(input()) G=[[0 for j in range(n)] for j in range(n)] for i in range(n): l=list(map(int,input().split())) u=l[0] k=l[1] for j in range(2,k+2): v=l[j] G[u-1][v-1]=1 for i in range(n): 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,730
s024415234
p02237
u318430977
1529681953
Python
Python3
py
Accepted
20
6384
364
def print_list(a): for x in a[:-1]: print(x, end=" ") print(a[-1]) def print_mat(a): for i in range(len(a)): print_list(a[i]) n = int(input()) adj = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): s = [int(x) for x in input().split()] u = s[0] for v in s[2:]: ...
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,731
s022518739
p02237
u063056051
1529748840
Python
Python3
py
Accepted
20
6384
247
n=int(input()) list1=[[0 for i in range(n)] for j in range(n)] #print(list1) for i in range(n): a=list(map(int,input().split())) #print(a) if a[1]>0: for j in range(2,len(a)): list1[i][a[j]-1]=1 for i in range(n): print(*list1[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,732
s853693450
p02237
u405027099
1530006715
Python
Python3
py
Accepted
20
6392
321
n=int(input()) a=[[0 for i in range(n)]for j in range(n)] for i in range(n): p=[int(x) for x in input().split()] for j in range(n): if j+1 in p[2:]: a[i][j]=1 """for i in range(n): for j in range(n): print(a[i][j],"",end="") print("") """ 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,733
s107617830
p02237
u398978447
1530071639
Python
Python3
py
Accepted
30
6392
347
n=int(input()) v=[] u=0 e=0 A=[[0 for j in range(n)]for i in range(n)] for i in range(n): S=input().split() if S[1]!=0: for j in range(int(S[1])): A[i][int(S[2+j])-1]=1 for i in range(n): for j in range(n): if j!=n-1: print(A[i][j],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,734
s644488198
p02237
u148477094
1530078793
Python
Python3
py
Accepted
20
5676
216
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,735
s277828636
p02237
u252641015
1530078896
Python
Python3
py
Accepted
30
6392
364
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,736
s659507628
p02237
u007270338
1530119518
Python
Python3
py
Accepted
20
5680
306
#coding:utf-8 n = int(input()) mtrx = [[0 for i in range(n)] for j in range(n)] for i in range(n): data = list(input().split()) adjs = int(data[1]) for adj in range(adjs): j = int(data[adj+2]) - 1 mtrx[i][j] = 1 for col in mtrx: print(" ".join([str(num) for num in col]))
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,737
s894689760
p02237
u912237403
1375418612
Python
Python
py
Accepted
20
4300
299
import sys 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,738
s134995093
p02237
u782850731
1380686306
Python
Python
py
Accepted
20
4244
288
#!/usr/bin/env python from __future__ import division, print_function from sys import stdin def main(): num = int(stdin.readline()) for _ in xrange(num): L = [int(s) for s in stdin.readline().split()][2:] print(*(int(i in L) for i in xrange(1, num+1))) 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,739
s790843770
p02237
u140201022
1389279895
Python
Python
py
Accepted
20
4664
368
# -*- coding:utf-8 -*- #from __future__ import print_function import time import sys import io import re import math start = time.clock() i = 0 n=int(raw_input()) l=[[0 for jc in range(n)] for _ in range(n)] for a in range(n): jk=map(int, raw_input().split()) for x in range(jk[1]): l[jk[0]-1][jk[x+2]-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,740
s336938344
p02237
u327396500
1597761129
Python
Python3
py
Accepted
20
6396
348
import sys input = sys.stdin.readline n = int(input()) G = {i: [] for i in range(1, n+1)} for _ in range(n): tmp = list(map(int, input().split())) G[tmp[0]] += tmp[2:] if tmp[1]>0 else [] adj = [[0]*(1+n) for _ in range(1+n)] for i in range(1, n+1): for j in G[i]: adj[i][j] = 1 for i 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,741
s136789296
p02237
u754923116
1597454185
Python
Python3
py
Accepted
20
5688
386
def main(N,A): A_ans = [[0]*N for _ in range(N)] for i in range(N): for j in range(A[i][1]): tmp = A[i][j+2] #print(tmp) A_ans[i][tmp-1] = 1 return A_ans N = int(input()) A = [list(map(int,input().split())) for _ in range(N)] A_ans = main(N,A) 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,742
s249573139
p02237
u880802684
1597378681
Python
Python3
py
Accepted
20
5668
268
n = int(input()) graph = [[0] * n for _ in range(n)] for i in range(n): data = [int(i) for i in input().split()] for j in range(data[1]): node = data[2 + j] - 1 graph[i][node] = 1 for line in graph: print(" ".join(str(i) for i in 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,743
s148321044
p02237
u733357255
1597123136
Python
Python3
py
Accepted
20
6388
260
n = int(input()) a = [list(map(int,input().split())) for i in range(n)] matrix = [[0 for i in range(n)] for i in range(n)] for i in range(n): if len(a[i])>2: b = a[i][2:] for j in b: matrix[i][j-1] = 1 print(*matrix[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,744
s584239959
p02237
u793520502
1597039285
Python
Python3
py
Accepted
20
6384
293
import sys input = sys.stdin.readline def getNeighbor(A, i): a = len(A) for k in range(2, a): C[i][A[k]-1] = 1 N = int(input()) C = [[0]*N for _ in range(N)] for i in range(N): A = list(map(int, input().split())) getNeighbor(A,i) 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,745
s952738969
p02237
u636645824
1596560449
Python
Python3
py
Accepted
20
6380
233
n = int(input()) mat = [[0]*n for _ in range(n)] for _ in range(n): In = list(map(int, input().split())) u, k, vs = In[0], In[1], In[2:] for v in vs: mat[u - 1][v - 1] = 1 for i in range(n): print(*mat[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,746
s619869384
p02237
u914515588
1596465694
Python
Python3
py
Accepted
50
7912
1,137
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array # from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall # from decimal import Decimal # from collections import defaultdict, deque sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = ...
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,747
s896014950
p02237
u053277556
1595731035
Python
Python3
py
Accepted
20
6388
242
n = int(input()) Adj = [list(map(int, input().split())) for _ in range(n)] m = [[0 for j in range(n)] for i in range(n)] for i in range(n): if Adj[i][1]>0: for a in Adj[i][2:]: m[i][a-1] = 1 for e in m: print(*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,748
s969732195
p02237
u491421284
1595255689
Python
Python3
py
Accepted
20
5668
320
n = int(input()) A = [[0] * n for i in range(n)] for i in range(n): row = [ int(r) for r in input().split()] u = row[0] - 1 if (row[1] > 0): for j in range(row[1]): v = row[2 + j] - 1 A[u][v] = 1 for i in range(n): print(" ".join([str(st) for st in 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,749
s800482871
p02237
u048101135
1595157661
Python
Python3
py
Accepted
20
6392
290
# coding: utf-8 # Your code here! n = int(input()) ans = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): adj = list(map(int,input().split())) if adj[1] != 0: for j in range(2,2+adj[1]): ans[i][adj[j]-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,750
s931012315
p02237
u820092408
1595147698
Python
Python3
py
Accepted
20
6384
284
n = int(input()) Adj = [] for i in range(n): X = list(map(int, input().split()))[2:] for j in range(len(X)): X[j] -= 1 Adj.append(X) A = [[0]*n for _ in range(n)] for i in range(n): for j in Adj[i]: A[i][j] = 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,751
s760392408
p02237
u434132766
1595059199
Python
Python3
py
Accepted
20
5616
172
N = int(input()) for i in range(N): tmp = input().split() ans = [0]*N for j in range(int(tmp[1])): ans[int(tmp[2+j])-1] = 1 print(*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,752
s382426417
p02237
u819143290
1594944367
Python
Python3
py
Accepted
20
6388
238
#演習2-10 n = int(input()) mat = [[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): mat[i][int(cmd[2+j])-1] = 1 for i in mat: 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,753
s210893442
p02237
u802474686
1594629989
Python
Python3
py
Accepted
20
5676
239
n=int(input()) adj=[list(map(int,input().split())) for _ in range(n)] lst=[[0 for i in range(n)] for j in range(n)] for x in adj: u,v=x[0],x[2:] for y in v: lst[u-1][y-1]=1 for x in lst: print(" ".join(map(str,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,754
s484754008
p02237
u913305001
1594628416
Python
Python3
py
Accepted
20
6384
250
N = int(input()) G = [[0 for _ in range(N)] for _ in range(N)] for i in range(N): u,k,*varray = map(int,input().split()) for v in varray: G[u-1][v-1] = 1 # for j in range(N): # print(G[i][j]) for row in G: 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,755
s695012531
p02237
u222972395
1594563892
Python
Python3
py
Accepted
30
5676
401
n = int(input()) l = [] tmp = 0 for _ in range(n): a = list(map(int,input().split())) l.append(a) if a[len(a)-1] > tmp: tmp = a[len(a)-1] ans = [[0 for i in range(tmp)] for j in range(n)] for i in range(n): if l[i][1] > 0: for j in range(2,len(l[i])): tmp1 = l[i][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,756
s630340757
p02237
u748843150
1594123790
Python
Python3
py
Accepted
30
5688
395
n=int(input()) graph={} def show(nums): for i in range(len(nums)): if i!=0: if i!=len(nums)-1: print(nums[i],end=" ") else: print(nums[i]) for i in range(n): tmp=list(map(int,input().split())) graph[tmp[0]]=[0 for j in range(n+1)] for k 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,757
s021230051
p02237
u878424017
1594046590
Python
Python3
py
Accepted
20
6384
207
n = int(input()) M = [[0 for _ in range(n)] for _ in range(n)] for _ in range(n): a,*b = map(int,input().split()) a -= 1 for i in b[1:]: M[a][i-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,758
s059763694
p02237
u973203074
1593548220
Python
Python3
py
Accepted
30
5608
281
n = int(input()) for i in range(n): s = [int(x) for x in input().split()] s.reverse() u, k = s.pop(), s.pop() se = set() for j in range(k): se.add(s.pop()) ans = [] for i in range(1, n + 1): ans.append(int(i in se)) print(*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,759
s480170331
p02237
u171087702
1593053202
Python
Python3
py
Accepted
20
5600
207
n = int(input()) for i in range(n): ans = [0] * n tmp = list(map(int, input().split())) u, k, v = tmp[0], tmp[1], tmp[2:] for j in v: ans[j-1] = 1 print(' '.join(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,760
s471481814
p02237
u864060739
1593048819
Python
Python3
py
Accepted
20
6380
227
N = int(input()) A = [[0]*N for _ in range(N)] for _ in range(N): l = list(map(int, input().split())) u, k = l.pop(0), l.pop(0) row = A[u-1] for x in l: row[x-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,761
s769139059
p02237
u742290340
1592815239
Python
Python3
py
Accepted
20
5668
208
n=int(input()) ans=[[0]*n for _ in range(n)] for _ in range(n): v,k,*varray= map(int,input().split()) for i in varray: ans[v-1][i-1]=1 for i in range(n): print(" ".join(map(str,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,762
s519766915
p02237
u903393228
1592815055
Python
Python3
py
Accepted
20
5608
166
n = int(input()) for i in range(n): a = list(map(int,input().strip().split())) b = [str(int(i+1 in a[2:])) for i in range(n)] L=' '.join(b) 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,763
s431467210
p02237
u647214684
1592814780
Python
Python3
py
Accepted
20
5680
242
N = int(input()) ans = [] for i in range(N): a = list(map(int, input().split())) pre = [0 for _ in range(N)] for k in a[2:]: pre[k-1] = 1 ans.append(pre) for i in range(N): print(' '.join(list(map(str, 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,764
s756049619
p02237
u233634805
1592790979
Python
Python3
py
Accepted
20
6384
228
N = int(input()) matrix = [[0] * N for _ in range(N)] for i in range(N): tmp = list(map(int, input().split())) for j in range(tmp[1]): matrix[tmp[0]-1][tmp[j+2]-1] = 1 for i in range(N): print(*matrix[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,765
s339139451
p02237
u121616304
1592664540
Python
Python3
py
Accepted
20
6388
297
N=int(input()) #S = [[0 for j in range(3)] for i in range(2)] 2行3列の場合 S = [[0 for j in range(N)] for i in range(N)] for i in range(N): T=list(map(int,input().split())) if T[1]!=0: for j in range(T[1]): S[i][T[j+2]-1]=1 for i in S: 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,766
s690038214
p02237
u500034977
1592424992
Python
Python3
py
Accepted
20
5640
300
n = int(input()) a = [[0]*n for x in range(n)] for i in range(n): nood = list(map(int,input().split())) nood_elements = nood[0]-1 for j in range(2,len(nood)): a[nood_elements][nood[j]-1] += 1 for j in range(n-1): print(a[nood_elements][j],end=" ") print(a[nood_elements][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,767
s793544876
p02237
u390052013
1591862110
Python
Python3
py
Accepted
20
6392
274
def resolve(): n = int(input()) V = [list(map(int, input().split())) for _ in range(n)] ans = [[0 for _ in range(n)] for _ in range(n)] for v, k, *a in V: for j in a: ans[v - 1][j - 1] = 1 for a in ans: print(*a) resolve()
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,768
s614099226
p02237
u512884261
1591797543
Python
Python3
py
Accepted
20
6764
686
import sys, collections input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = 10**10 def I(): return int(input()) def F(): return float(input()) def SS(): return input() def LI(): return [int(x) for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] def LF(): return ...
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,769
s216694315
p02237
u114583562
1591609814
Python
Python3
py
Accepted
20
6388
214
n = int(input()) l = [list(map(int,input().split())) for _ in range(n)] l1 = list( [0 for i in range(n)] for _ in range(n)) for i in l: a,b,*c = i for j in c: l1[a-1][j-1] = 1 for k in l1: print(*k)
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,770
s558364380
p02237
u450519077
1591531876
Python
Python3
py
Accepted
20
6388
187
import sys n = int(input()) G = [[0] * n for i in range(n)] for i in range(n): u, k, *A = map(int, input().split()) for a in A: G[i][a-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,771
s097513566
p02237
u300329459
1591281163
Python
Python3
py
Accepted
40
5628
385
n = int(input()) nodes = [] for i in range(n): tmp_nodes = [int(x) for x in input().split()] tmp = 2 j = 1 while j <= n: if j != 1: print(" ", end = "") if tmp < len(tmp_nodes) and j == tmp_nodes[tmp]: print(1, end = "") tmp += 1 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,772
s876497976
p02237
u800829827
1590907615
Python
Python3
py
Accepted
20
5672
314
n=int(input()) L=[] for l in range(n): L.append([]) M=[] for m in range(n): mm=[0]*n M.append(mm) for i in range(n): inp=list(map(int,input().split())) #print() L[inp[0]-1]=inp[2:] for i,l in enumerate(L): for k in l: M[i][k-1]=1 for m in M: 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,773
s270145429
p02237
u219344987
1590836932
Python
Python3
py
Accepted
20
6392
314
n = int(input()) ls = [[] for i in range(n)] for i in range(n): s = list(map(int,input().split())) for j in range(s[1]): ls[i].append(s[j+2]) ls2 = [[0 for i in range(n)] for i in range(n)] for i in range(len(ls)): for j in range(len(ls[i])): ls2[i][ls[i][j]-1] += 1 print(*ls2[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,774
s845614584
p02237
u153034461
1590765520
Python
Python3
py
Accepted
30
7104
609
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy if __name__ == "__main__": n = int(input()) edge = [] for i in range(n): u,k,*v_li = map(int,input().split()) u-= 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,775
s909830235
p02237
u945415253
1590557812
Python
Python3
py
Accepted
30
5680
315
n = int(input()) lst = [] for i in range(n): lst.append(list(map(int,input().split()))) out_list = [[0 for i in range(n)] for l in range(n)] for a,in_lst in enumerate(lst): for x in range(in_lst[1]): out_list[a][in_lst[x+2]-1] = 1 for o1 in out_list: print(' '.join([str(x) for x in o1]))
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,776
s629913164
p02237
u847316328
1589847716
Python
Python3
py
Accepted
20
5672
210
n = int(input()) G = [[0]*n for i in range(n)] for i in range(n): u,k,*vs = map(int,input().split()) for j in range(len(vs)): G[u-1][vs[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,777
s831727075
p02237
u124936061
1589746722
Python
Python3
py
Accepted
20
5668
827
n=int(input()) #รับจำนวน node ทั้งหมด m=[[0]*n for i in range(n)] #สร้าง array matrix 0 ขนาดเท่าจำนวน node for i in range(n): tmp=list(map(int,input().split())) #วน loop ตามจำนวน node รับค่าข้อมูลแต่ละ node #ตน 0 คือ node , ตน 1 คือ จำนวน vertex ตน 2 เป็นต้นไปคือ vertex for j in tmp[2:]: m[i][j-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,778
s889058293
p02237
u704109794
1589714804
Python
Python3
py
Accepted
20
5612
192
n = int(input()) for i in range(n): u = list(map(int, input().split())) result = [0]*n count = u[1] for j in range(count): result[u[j+2]-1] = 1 print(*result)
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,779
s509645537
p02237
u798363880
1589428487
Python
Python3
py
Accepted
20
6384
223
N=int(input()) matrix=[[0 for i in range(N)] for j in range(N)] for i in range(N): a,b,*c=input().split() a=int(a) for k in c: matrix[a-1][int(k)-1]=1 for i in range(len(matrix)): print(*matrix[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,780
s896617265
p02237
u119355204
1589424086
Python
Python3
py
Accepted
20
5676
252
N=int(input()) M=[[0]*N for n in range(N)] for n in range(N): input_temp = list(map(int,input().split())) for m in range(input_temp[1]): ad = input_temp[m+2] M[n][ad-1] = 1 for m in M: 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,781