ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [๋ฐฑ์ค€] 11383 ๋šŠ with Python
    PS 2023. 4. 13. 15:08
    728x90
    ๋ฐ˜์‘ํ˜•

    ๐Ÿ“Œ BOJ 11383 ๋šŠ

    ๐Ÿ’ก ์กฐ๊ฑด

    1. ์ •์šฐ๋Š” "๋šŠ"๊ณผ "๋Œ๋”"์„ ์˜๋ฏธํ•˜๋Š” ๋‘ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ›์•˜๋‹ค. ๊ณผ์—ฐ ๋‘ ๊ทธ๋ฆผ์ด ๊ฐ™์€์ง€ ๊ฒ€์‚ฌํ•ด๋ณด์ž.
    2. ์ฆ‰ N× M ํฌ๊ธฐ์˜ ์ด๋ฏธ์ง€์™€ N ×2 M ํฌ๊ธฐ์˜ ์ด๋ฏธ์ง€๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ
      ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€๋กœ๋กœ ๋‘ ๋ฐฐ๋กœ ๋Š˜์ด๋ฉด ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€๊ฐ€ ๋˜๋Š”์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฌธ์ œ.
    3. ์ž…๋ ฅ์˜ ์ฒซ ๋ฒˆ์งธ ์ค„์— N, M (1 ≤ N, M ≤ 10)์ด ์ฃผ์–ด์ง„๋‹ค.
      ๋‹ค์Œ N๊ฐœ์˜ ์ค„์˜ ๊ฐ ์ค„์—๋Š” M๊ฐœ์˜ ๋ฌธ์ž๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.
    4. ๋‹ค์Œ N๊ฐœ์˜ ์ค„์˜ ๊ฐ ์ค„์—๋Š” 2M๊ฐœ์˜ ๋ฌธ์ž๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋ชจ๋“  ๋ฌธ์ž๋Š” ์˜๋ฌธ ์•ŒํŒŒ๋ฒณ ๋Œ€๋ฌธ์ž ํ˜น์€ ์†Œ๋ฌธ์ž์ด๋‹ค.
    5. ์ฒซ ๋ฒˆ์งธ๋กœ ์ฃผ์–ด์ง„ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€๋กœ๋กœ ๋‘ ๋ฐฐ๋กœ ๋Š˜๋ ธ์„ ๋•Œ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€๊ฐ€ ๋œ๋‹ค๋ฉด "Eyfa"์„ ์ถœ๋ ฅ, ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด "Not Eyfa"์„ ์ถœ๋ ฅ
    6. ๋ฌธ์ž์—ด, ๊ตฌํ˜„ ์œ ํ˜•์˜ ๋ฌธ์ œ

    ๐Ÿ”– ์˜ˆ์ œ ๋ฐ ์‹คํ–‰๊ฒฐ๊ณผ

    ์˜ˆ์ œ 1

    1 5
    ABCDE
    AABBCCDDEE

    ์‹คํ–‰๊ฒฐ๊ณผ 1

    Eyfa

    ์˜ˆ์ œ 2

    ABCDE
    AABBCCDDEF

    ์‹คํ–‰๊ฒฐ๊ณผ 2

    Not Eyfa

    ์˜ˆ์ œ 3

    2 2
    AB
    CD
    AABB
    CCDD

    ์‹คํ–‰๊ฒฐ๊ณผ 3

    Eyfa

    โŒจ๏ธ ๋ฌธ์ œ ํ’€์ด

    1. ์ž…๋ ฅ์„ ๋ฐ›์€ ๋ฌธ์ž์—ด์„ ๊ด€๋ฆฌํ•  ๋ฆฌ์ŠคํŠธ๋ฅผ ์ƒ์„ฑํ•ด, n๊ฐœ ๋งŒํผ ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.
    2. ์ž…๋ ฅ์„ ๋ฐ›์€ ๋ฌธ์ž์—ด์„ ๊ด€๋ฆฌํ•  ๋ฆฌ์ŠคํŠธ์— ๋„ฃ๊ธฐ ์ „, ์ˆœํšŒ๋ฅผ ํ•˜๋ฉด์„œ ๊ฐ ๋ฌธ์ž๋ฅผ 2๊ฐœ์”ฉ ์ด์–ด๋ถ™์ธ๋‹ค.
    3. (1)~(2) ๋ฒˆ์—์„œ ์ œ์ž‘ํ•œ ๋ฌธ์ž์—ด๊ณผ ์ดํ›„์— ์ž…๋ ฅ ๋ฐ›์€ ๋น„๊ตํ•  ๋ฌธ์ž์—ด์„ ๋น„๊ตํ•ด, ํ•˜๋‚˜๋ผ๋„ ํ‹€๋ ธ์„ ์‹œ, Not Eyfa ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
    4. ํ•จ์ˆ˜๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด ๊ฒฐ๊ณผ๋ฅผ return ํ•ด์ฃผ๋ฉด ์ฝ”๋“œ๊ฐ€ ๋” ์‰ฝ๋‹ค.

    ๐Ÿ–ฅ ์†Œ์Šค ์ฝ”๋“œ

    from sys import stdin
    
    inp = stdin.readline
    n, m = map(int, inp().split())
    be, af = [], []
    
    for i in range(n):
        res = ''
        s = stdin.readline().rstrip()
        for i in s:
            res += i * 2
    
        be.append(res)
    
    for i in range(n):
        af.append(stdin.readline().rstrip())
    
    
    def get_res():
        for i in range(n):
            if be[i] != af[i]:
                return 0
    
        return 1
    
    
    print('Eyfa' if get_res() else 'Not Eyfa')
    ๋ฐ˜์‘ํ˜•

    ๋Œ“๊ธ€

Designed by Tistory.