File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys
2+
3+ input = sys .stdin .readline
4+
5+ p = [0 ] * 101
6+ p [1 ] = 1
7+ p [2 ] = 1
8+
9+ for i in range (3 , 101 ):
10+ p [i ] = p [i - 3 ] + p [i - 2 ]
11+
12+ t = int (input ())
13+ for _ in range (t ):
14+ n = int (input ())
15+
16+ print (p [n ])
Original file line number Diff line number Diff line change 1+ import sys
2+
3+ input = sys .stdin .readline
4+
5+ n = int (input ())
6+ friends = [list (map (str , input ().rstrip ())) for _ in range (n )]
7+ relation = [[0 ] * n for _ in range (n )]
8+
9+
10+ for k in range (n ):
11+ for i in range (n ):
12+ for j in range (n ):
13+ if i == j :
14+ continue
15+ if (friends [i ][k ] == 'Y' and friends [k ][j ] == 'Y' ) or friends [i ][j ] == 'Y' :
16+ relation [i ][j ] = 1
17+
18+ print (relation )
19+ max_count = 0
20+ for r in relation :
21+ max_count = max (max_count , sum (r ))
22+ print (max_count )
Original file line number Diff line number Diff line change 1+ from collections import *
2+
3+ def solution (begin , target , words ):
4+
5+ if target not in words :
6+ return 0
7+
8+ q = deque ([(begin , 0 )])
9+ while q :
10+ now , cnt = q .popleft ()
11+ if now == target :
12+ return cnt
13+
14+ for word in words :
15+ tmp_cnt = 0
16+ for i in range (len (now )):
17+ if now [i ] != word [i ]:
18+ tmp_cnt += 1
19+ if tmp_cnt == 1 :
20+ q .append ([word , cnt + 1 ])
You can’t perform that action at this time.
0 commit comments