File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+ input = sys .stdin .readline
3+
4+ st1 = list (input ().rstrip ()) # 첫째 줄에 입력받은 문자열 (커서 기준 왼쪽)
5+ st2 = [] # 커서 기준 오른쪽
6+
7+ for _ in range (int (input ().strip ())):
8+ command = input ().split ()
9+ if command [0 ] == 'L' : # L이면 커서가 왼쪽으로 한칸 옮긴 것처럼 표현
10+ if st1 :
11+ st2 .append (st1 .pop ())
12+ elif command [0 ] == 'D' : # D이면 커서가 오른쪽으로 한칸 옮긴 것처럼
13+ if st2 :
14+ st1 .append (st2 .pop ())
15+ elif command [0 ] == 'B' : # B이면 왼쪽에 있는 문자가 삭제된 것처럼
16+ if st1 :
17+ st1 .pop ()
18+ else :
19+ st1 .append (command [1 ]) # P $이면 st1에 추가되게끔 함으로써 커서 왼쪽에 문자가 추가된 것처럼 표현
20+
21+ st1 .extend (reversed (st2 )) # 뒤집어서 추가
22+ print ('' .join (st1 ))
Original file line number Diff line number Diff line change 1+ import sys
2+ input = sys .stdin .readline
3+
4+ n , k = input ().split ()
5+ player = set ()
6+
7+ for _ in range (int (n )):
8+ player .add (input ().rstrip ())
9+
10+ p = len (player ) # 중복이 제외된 플레이어 수
11+
12+ if k == 'Y' : # 윷놀이
13+ print (p )
14+ elif k == 'F' : # 같은 그림 찾기
15+ print (p // 2 )
16+ else : # 원카드
17+ print (p // 3 )
Original file line number Diff line number Diff line change 1+ def solution (s ):
2+ a , b = 0 , 0
3+ while s != '1' :
4+ a += 1
5+ num = s .count ('1' )
6+ b += len (s ) - num
7+ s = bin (num )[2 :]
8+ return [a , b ]
You can’t perform that action at this time.
0 commit comments