본문 바로가기
Python/백준

[python 백준] 1236번 성 지키기

by Meaning_ 2022. 4. 11.
728x90
반응형

교양시험대비! 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
row,col=map(int,input().split())
 
lst=[]
 
for i in range(row):
    lst.append(list(map(str,input().strip())))
row_cnt=0
col_cnt=0
 
 
#행
for i in range(row):
    if "X" not in lst[i]:
      row_cnt+=1
#열
 
for i in range(col):
    std=row
    for j in range(row):
        if "X" in lst[j][i]:
            std-=1
    if(std==row):
        col_cnt+=1
 
 
# row와 col중 더 작은거
 
print(max(row_cnt,col_cnt))
cs

 

 

 

이차원 배열 관련 

하도 안하니까 다 까먹음.. 하긴 파이썬 한지도 1년넘었으니..

1
2
3
4
5
6
7
8
9
10
11
12
row,col=map(int,input().split())
 
lst=[]
 
for i in range(row):
    lst.append(list(map(int,input().split())))
 
for i in range(row):
    for j in range(col):
        print(lst[i][j],end=" ")
    print("\n")
 
cs

 

728x90
반응형

'Python > 백준' 카테고리의 다른 글

[python 백준] 실버3/백준 13414번 수강신청  (0) 2021.06.20

댓글