MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon 128

#10809 ์•ŒํŒŒ๋ฒณ ์ฐพ๊ธฐ - python

S = input() tmp = [] i ,j= 0,0 for i in range(26): tmp.append(-1) for j in range(len(S)): if (tmp[ord(S[j])-97]==-1): tmp[ord(S[j])-97] = j print(*tmp, sep=" ") ๊ฐ„๋‹จํ•œ ์›๋ฆฌ๋งŒ ์•Œ๋ฉด ๋งค์šฐ ์‰ฝ๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋‹ค! 1) -1 ๋ฏธ๋ฆฌ ๋ฐฐ์น˜ํ•ด๋‘” tmp ๋ฆฌ์ŠคํŠธ ๋งŒ๋“ค์–ด๋‘๊ณ  2) ( ๋ฌธ์ž.์•„์Šคํ‚ค ์ฝ”๋“œ ๊ฐ’ - 97 ) == -1 3) j ์œ„์น˜ ๋„ฃ์–ด์ค€๋‹ค. ๋ฌธ์ž๋Š” a (97) ~ z (122) ๊นŒ์ง€์˜ ๊ฐ’์ด ์ฃผ์–ด์ ธ์žˆ๋Š” ์ƒํƒœ. ์—ฌ๊ธฐ์—์„œ -97 ์„ ํ•ด์ฃผ๊ฒŒ๋˜๋ฉด a ๋ถ€ํ„ฐ z ๊นŒ์ง€์˜ ๊ฐ’์„ 0 ~ 26์œผ๋กœ ์žก์„ ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค ! ์ฆ‰, tmp[0~26] ์— S ๋ฌธ์ž ์ธ๋ฑ์Šค๊ฐ’ ( j ) ์„ ์‰ฝ๊ฒŒ ๋„ฃ์„ ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค. >..

#27866, #2743, #9086, #11654 - python

S = input() i = int(input()) print(S[i-1]) ๐Ÿ’ฌ ํŒŒ์ด์ฌ์€ ๊ธฐ๋ณธ์œผ๋กœ ๋ฌธ์ž์—ด์ด๋‹ค. ๐Ÿ’ฌ ๋ฌธ์ž ์„ ํƒ ์—ฐ์‚ฐ์ž (์ธ๋ฑ์‹ฑ) : [] ๋ฌธ์ž์—ด ๋‚ด๋ถ€ ๋ฌธ์ž ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•˜๋Š” ์—ฐ์‚ฐ์ž์ด๋‹ค. S = input() print(len(S)) ๐Ÿ’ฌ len(): ๋ฌธ์ž์—ด ๊ธธ์ด ๋ฐ˜ํ™˜ (๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์˜ ๊ธธ์ด(๋˜๋Š” ์š”์†Œ์˜ ์ˆ˜)๋ฅผ ๋ฐ˜ํ™˜ํ•จ) T = int(input()) S,tmp= [],[] for i in range(T): S.append(input()) tmp = S[i] print(tmp[0]+tmp[-1]) ๋ฌธ์ž์—ด๋“ค์„ ๋ฆฌ์ŠคํŠธ์— ๋‹ด์•„์˜ค๊ณ  ์ž„์‹œ ๋ฆฌ์ŠคํŠธ์— ๋ฌธ์ž์—ด ํ•˜๋‚˜๋ฅผ ์˜ฎ๊ฒจ์„œ tmp[0] ์ฒซ๋ฒˆ์งธ ๊ฐ’ tmp[-1] ๋งˆ์ง€๋ง‰๊ฐ’ ์ถœ๋ ฅ ๐Ÿ’ฌ ๋ฌธ์ž์—ด ๊ฑฐ๊พธ๋กœ ์ถœ๋ ฅ ( [-1] ์ธ๋ฑ์Šค) : ~ ๋’ค๋ถ€ํ„ฐ ์ถœ๋ ฅ๋œ๋‹ค. print(..

#10811 ๋ฐ”๊ตฌ๋‹ˆ - python

> N,M=map(int,input().split()) s,tmp= [],[] for x in range(N): s.append(x+1) for y in range(M): i,j = map(int,input().split()) tmp = s[i-1:j] # (0~n-1) tmp.reverse() s[i-1:j] = tmp print(*s, sep=" ") 1 ~ 4 ์ด๋ฉด ์ธ๋ฑ์Šค์— ๋งž๊ฒŒ 0 ~ 4 ์œผ๋กœ ๋ฐ”๊ฟ”์ค˜์•ผํ•˜๋Š”๋ฐ ๋ฆฌ์ŠคํŠธ ๋ฒ”์œ„ ์„ ํƒ ์—ฐ์‚ฐ์ž๋Š” 0 ~ n-1 ๋ฒ”์œ„์ด๋ฏ€๋กœ ( i - 1 ~ j ) ํ•ด์ฃผ๋ฉด ๋œ๋‹ค ! > s[i-1:j].reverse() ์ฒ˜์Œ์—๋Š” ์ด๋Ÿฐ์‹์œผ๋กœ ๋„์ „ํ•ด๋ดค๋Š”๋ฐ ์•ˆ๋๋‹ค ^_^ ์ถœ๋ ฅํ•ด๋ณด๋ฉด None ๊ฐ’๋งŒ ๋‚˜์˜จ๋‹ค ใ…  v.append(s[i-1:j]) v.reverse() s.append(v) ๊ทธ๋ž˜..

#3052 ๋‚˜๋จธ์ง€ -python

a=[] for i in range(10): n = (int(input())%42) if n not in a: a.append(n) print(len(a)) > a=[] for i in range(10): a.append(int(input())%42)) ์‹œ์ž‘์„ ๋ฐ”๋กœ ๋‚˜๋จธ์ง€ ๊ฐ’์„ ๊ณ„์‚ฐํ•ด์„œ ๋„ฃ์–ด๋ฒ„๋ฆฐ๋•์— ๋ฆฌ์ŠคํŠธ์— ๋‹ด๊ธด ๊ฐ’์ด ๊ฐ™์€ ๊ฐ’์ด ์•„๋‹Œ ๊ฑธ ์ฐพ์•„๋‚ด๋ ค๋ฉด ๊ฐ’ ํ•˜๋‚˜์— ํ•œ๋ฐ”ํ€ด์”ฉ ๋Œ๋ฉฐ ๋น„๊ตํ•ด์•ผ๋˜๋Š”๋ฐ....??? ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ฝ”๋“œ๋ฅผ ๋‹ค ์ ์–ด์•ผํ•˜๋Š”๊ฑด๊ฐ€ ์‹ถ์œผ๋ฉด์„œ ๐Ÿ˜จ ๋ณต์žกํ•œ ์ƒ๊ฐ์„ ํ–ˆ๋Š”๋ฐ.... ๋ฆฌ์ŠคํŠธ์— ๋„ฃ๊ธฐ ์ „์— ๋จผ์ € ๋‚˜๋จธ์ง€ ๊ฐ’์„ ๋ณ€์ˆ˜์— ๋„ฃ๊ณ  ํ•ด๋‹น ๋ณ€์ˆ˜๊ฐ’์ด ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š”์ง€ ์—†๋Š”์ง€ ํ™•์ธํ•œ ๋’ค , ์ถœ๋ ฅํ•˜๋ฉด ํŽธํ–ˆ๋˜ ๊ฒƒ... ๐Ÿ˜Š > ๐Ÿ”” ๋ฆฌ์ŠคํŠธ๋ช….append() : ๋ฆฌ์ŠคํŠธ์— ๊ฐ’ ์ถ”๊ฐ€ํ•˜๊ธฐ ๐Ÿ”” ๊ฐ’ in ๋ฆฌ์ŠคํŠธ / ๊ฐ’ not in ๋ฆฌ์ŠคํŠธ ..

#5597 ๊ณผ์ œ์•ˆ๋‚ด์‹ ๋ถ„ - python

a=[] i,j = 0,0 for i in range(28): a.append(int(input())) a.sort() for j in range(30): if (j+1 not in a) == True: print(j+1) ์ˆ™์ œ ์ œ์ถœํ•œ 28๋ช… ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„์ฃผ๊ณ , ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•ด์ค€๋‹ค. ์ดํ›„ not in ์—ฐ์‚ฐ์ž + for ๋ฌธ์„ ํ†ตํ•ด ๋ฆฌ์ŠคํŠธ์— ์—†๋Š” ๊ฐ’์„ ์‰ฝ๊ฒŒ ์•Œ์•„๋‚ผ ์ˆ˜ ์žˆ๋‹ค. True ๊ฐ’์ด ์ถœ๋ ฅ๋˜๋ฉด ๋ฆฌ์ŠคํŠธ์— ์—†๋Š” ๊ฐ’์ด๋ฏ€๋กœ ๊ทธ ๊ฐ’์„ ์ถœ๋ ฅํ•ด์ฃผ๋ฉด ๋! > not in / in ์—ฐ์‚ฐ์ž ์ถœ๋ ฅ ์•ˆ๋˜๋Š” ์ด์œ  for j in range(30): if (j+1) not in a == True: print(j+1) ์ดˆ๋ฐ˜์— ๊ณ„์† ๊ฐ’ ์ถœ๋ ฅ์ด ์•ˆ๋˜๊ณ  ๋ง‰ํžˆ๋Š” ๊ฒƒ์ด๋‹ค! ๐Ÿ˜จ ๋ถ„๋ช… True ์— ๊ฑธ๋ ค์„œ ๊ฐ’ ๋‘๊ฐœ๊ฐ€ ์ถœ๋ ฅ๋˜์–ด์•ผํ•˜๋Š”๋ฐ .!!!!..

#10813 ๊ณต ๋ฐ”๊พธ๊ธฐ -python

N,M =map(int,input().split()) x,y = 0,0 a,tmp=[],0 for x in range(N): a.append((x+1)) for y in range(M) : i,j = map(int,input().split()) tmp = a[j-1] a[j-1] = a[i-1] a[i-1] = tmp print(*a, sep=" ") ๊ฐ’์„ ๋ฐ”๊ตฌ๋‹ˆ ๋ฒˆํ˜ธ์™€ ๋™์ผํ•˜๊ฒŒ ์ดˆ๊ธฐํ™” a.append((x+1)) tmp ๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐ’์„ ๋ฐ”๊ฟ”์ค€๋‹ค. > ๐Ÿ”” map (์ ์šฉ์‹œํ‚ฌ ํ•จ์ˆ˜, ์ ์šฉํ•  ๋ฐ˜๋ณต๊ฐ€๋Šฅํ•œ์ž๋ฃŒํ˜• ) : ๊ฐ’์„ ์ผ๊ด„๋กœ ๋ณ€ํ™˜ ๐Ÿ”” input().split() : ๊ณต๋ฐฑ์„ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌํ•˜์—ฌ ๊ฐ’์„ ๋ฐ›์Œ ๐Ÿ”” ๋ฆฌ์ŠคํŠธ๋ช….append() : ๋ฆฌ์ŠคํŠธ์— ๊ฐ’ ์ถ”๊ฐ€ํ•˜๊ธฐ ๐Ÿ”” print(*๋ฆฌ์ŠคํŠธ๋ช…, sep=" ") : ๋ฆฌ..

#10810 ๊ณต ๋„ฃ๊ธฐ - python

N,M = map(int,input().split()) L=[] a,b,c = 0,0,0 for a in range (N): L.append(0) for b in range (M): i,j,k = map(int,input().split()) for c in range (i-1,j): L[c] = k print(*L, sep=" ") ๋จผ์ € ๋ฐ”๊ตฌ๋‹ˆ N ๋ฒˆ์งธ ๊นŒ์ง€ 0์œผ๋กœ ์ฑ„์›Œ์ฃผ๊ณ  ์‹œ์ž‘ํ•œ๋‹ค. ์ดํ›„ i,j,k ๊ฐ’์„ ๋ฐ›์•„์˜จ๋‹ค. ex) 1,4,3 // ๋ฐ”๊ตฌ๋‹ˆ 1๋ฒˆ์งธ ~ 4๋ฒˆ์งธ ๋œป์ธ๋ฐ โ• ์‚ฌ์‹ค์ƒ 0๋ฒˆ์งธ ~ 3๋ฒˆ์งธ์ด๋‹ค.์ฆ‰ ๋ฐ˜๋ณต๋ฌธ ์‚ฌ์šฉ์‹œ ( i -1 , j ) ๋กœ ๋„ฃ์–ด์ค˜์•ผํ•œ๋‹ค. c๋Š” 0,1,2,3 ์ด ๋œ๋‹ค. L [c] ์ฐจ๋ก€๋Œ€๋กœ k ๊ฐ’์„ ๋„ฃ์–ด์ค€๋‹ค. > ๐Ÿ”” map (์ ์šฉ์‹œํ‚ฌ ํ•จ์ˆ˜, ์ ์šฉํ•  ๋ฐ˜๋ณต๊ฐ€๋Šฅํ•œ์ž๋ฃŒํ˜• ) : ๊ฐ’์„ ์ผ๊ด„๋กœ ..

#2562 - python

A =[] for i in range (9): A.append(int(input())) print(max(A)) for i in range (9): if(A[i] == max(A)): print(i+1) append() ํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋ฆฌ์ŠคํŠธ์— 9๊ฐœ ๊ฐ’์„ ๋ฐ›์•„์˜ค๊ณ  max() ํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋ฆฌ์ŠคํŠธ ์ค‘ ์ตœ๋Œ€๊ฐ’์„ ์ถœ๋ ฅํ•œ ๋’ค i ๋ฅผ 0~9 ๊นŒ์ง€ ๋Œ๋ ค์„œ ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ๊ฐ’๊ณผ ์ตœ๋Œ€๊ฐ’์ด ๊ฐ™์•„์ง€๋Š” ์ˆœ๊ฐ„์ด ์ตœ๋Œ€๊ฐ’์˜ ์ธ๋ฑ์Šค ๊ฐ’์ด ๋œ๋‹ค. = i ํ•˜์ง€๋งŒ ์ธ๋ฑ์Šค ๊ฐ’์€ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋ฏ€๋กœ ์ˆœ๋ฒˆ์„ ์ถœ๋ ฅํ•˜๋ ค๋ฉด +1 ์„ ํ•ด์ค˜์•ผํ•œ๋‹ค. i +1 > ๐Ÿ”” ๋ฆฌ์ŠคํŠธ์— ์š”์†Œ ์ถ”๊ฐ€ํ•˜๋Š” ํ•จ์ˆ˜ list.append(์š”์†Œ) list.insert(์œ„์น˜,์š”์†Œ) ๐Ÿ”” max(๋ฆฌ์ŠคํŠธ) : ๋ฆฌ์ŠคํŠธ์˜ ์ตœ๋Œ“๊ฐ’์„ ๋ฆฌํ„ดํ•œ๋‹ค.

#10818 - python

N = int(input()) A = list(map(int,input().split())) print(min(A),max(A)) > ๐Ÿ”” max(list) : ๋ฆฌ์ŠคํŠธ ๋‚ด๋ถ€์—์„œ ์ตœ๋Œ“๊ฐ’์„ ์ฐพ์•„์„œ ๋ฆฌํ„ดํ•ด์ค€๋‹ค. ๋ฆฌ์ŠคํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.! ex) max(1,2,3,4) ๐Ÿ”” min(list) : ์ตœ์†Ÿ๊ฐ’ ๐Ÿ”” sum(list) : ๋ชจ๋‘ ๋”ํ•œ๋‹ค.