Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11-H0ngJu #178

Merged
merged 2 commits into from
May 3, 2024
Merged

11-H0ngJu #178

merged 2 commits into from
May 3, 2024

Conversation

H0ngJu
Copy link
Collaborator

@H0ngJu H0ngJu commented Apr 7, 2024

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ

์‚ฌํƒ• ๊ฒŒ์ž„

โœ”๏ธ ์†Œ์š”๋œ ์‹œ๊ฐ„

30๋ถ„?

โœจ ์ˆ˜๋„ ์ฝ”๋“œ

๋ฌธ์ œ ํ•œ ์ค„ ์š”์•ฝ : ๊ฐ™์€ ์ƒ‰์˜ ์‚ฌํƒ•๋งŒ ๋จน์„ ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•  ๋•Œ, ์ธ์ ‘ํ•œ ๋‘ ์‚ฌํƒ•์„ ๋ฐ”๊ฟ”์„œ ๋จน์„ ์ˆ˜ ์žˆ๋Š” ์‚ฌํƒ•์˜ ์ตœ๋Œ€ ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐ (row ๋งŒ ๋จน๊ฑฐ๋‚˜ col๋งŒ ๋จน์–ด์•ผํ•จ)


๋ฌธ์ œ๋ฅผ ์ฝ๊ณ , ๋ฐฐ์—ด๋„ 50*50์ด๊ณ ,
๋”ฑํžˆ ๋– ์˜ค๋ฅด๋Š” ๊ฒŒ ์—†์–ด์„œ ๊ทธ๋ƒฅ ๊ตฌํ˜„์œผ๋กœ ์ ‘๊ทผํ–ˆ์Šต๋‹ˆ๋‹ค.


  1. ์ธ์ ‘ํ•œ ๋‘ ์‚ฌํƒ•์„ ๋ฐ”๊พผ๋‹ค.
  2. ๋ฐ”๊ฟจ์„ ๋•Œ, row๋กœ ๋จน์—ˆ์„ ๋•Œ์™€ col๋กœ ๋จน์—ˆ์„ ๋•Œ๋ฅผ ๋น„๊ตํ•ด์„œ ์ตœ๋Œ“๊ฐ’์„ ์ฐพ๋Š”๋‹ค.
  3. ์œ„์น˜๋ฅผ ๋ฐ”๊พผ ๋‘ ์‚ฌํƒ•์„ ์›์œ„์น˜
  4. 0,0,๋ถ€ํ„ฐ N-1,N-1๊นŒ์ง€ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ์ตœ๋Œ“๊ฐ’์„ ๊ฐฑ์‹ ํ•œ๋‹ค.




์ˆ˜๋„ ์ฝ”๋“œ๋Š” ๊ฐ„๋‹จํ•ด์„œ ๋ง๋ถ™์ผ ๋ง์ด ์—†๋„ค์šฉ ..?
๋ฐฑ์ค€ ๋‚œ์ด๋„๋Š” ๊ฐ€๋Š ํ•˜๊ธฐ๊ฐ€ ์–ด๋ ต๊ตฐ์š” ..


์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ถ„๋ฅ˜๋ฅผ ๋ณด๋‹ˆ๊นŒ ๊ตฌํ˜„, ๋ธŒ๋ฃจํŠธํฌ์Šค๋ผ์„œ ์ด๋ ‡๊ฒŒ ์ ‘๊ทผํ•˜๋Š”๊ฒŒ ๋งž๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

ใ…Ž.ใ…Ž
์ด ๋ฌธ์ œ ํ‘ธ๋‹ˆ๊นŒ ๋“œ๋””์–ด ์‹ค๋ฒ„๊ฐ€ ๋˜์—ˆ๋„ค์šฉ ๐Ÿ˜Ž๐Ÿ˜Ž๐Ÿ˜Ž๐Ÿ˜Ž


image

๐Ÿ“š ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ

Copy link
Member

@tgyuuAn tgyuuAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from collections import deque
import sys

def input(): return sys.stdin.readline().rstrip()

N = int(input())
board = []

for _ in range(N):
    board.append(list(input()))

dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]
visited = set()
answer = 1
for col in range(N):
    for row in range(N):
        for dir in range(4):
            new_col = col + dy[dir]
            new_row = row + dx[dir]

            if new_col < 0 or new_col >= N: continue
            if new_row < 0 or new_row >= N: continue
            if ((col, row, new_col, new_row)) in visited: continue
            if ((new_col, new_row, col, row)) in visited: continue

            visited.add(((col, row, new_col, new_row)))
            board[col][row], board[new_col][new_row] = board[new_col][new_row], board[col][row]
            
            temp = 0
            is_connect = False
            for check_col in range(N):
                if check_col == col:
                    is_connect = True
                    
                if board[check_col][row] == board[col][row]:
                    temp+=1
                    
                else: 
                    if is_connect: 
                        answer = max(answer, temp)
                        break
                    temp=0
            
            if is_connect: 
                answer = max(answer, temp)
            
            temp = 0
            is_connect = False
            for check_row in range(N):
                if check_row == row:
                    is_connect = True
                    
                if board[col][check_row] == board[col][row]:
                    temp+=1
                    
                else: 
                    if is_connect: 
                        answer = max(answer, temp)
                        break
                    temp=0
            
            if is_connect: 
                answer = max(answer, temp)
            
            temp = 0
            is_connect = False
            for check_col in range(N):
                if check_col == new_col:
                    is_connect = True
                    
                if board[check_col][new_row] == board[new_col][new_row]:
                    temp+=1
                    
                else: 
                    if is_connect: 
                        answer = max(answer, temp)
                        break
                    temp=0
            
            if is_connect: 
                answer = max(answer, temp)
            
            temp = 0
            for check_row in range(N):
                if check_row == new_row:
                    is_connect = True
                    
                if board[new_col][check_row] == board[new_col][new_row]:
                    temp+=1

                else: 
                    if is_connect: 
                        answer = max(answer, temp)
                        break
                    temp=0
            
            if is_connect: 
                answer = max(answer, temp)
                    
            board[col][row], board[new_col][new_row] = board[new_col][new_row], board[col][row]   
            
print(answer)

์ €๋„ ๊ทธ๋ƒฅ ๊ตฌํ˜„์œผ๋กœ ํ’€์—ˆ์Šต๋‹ˆ๋‹ค!!!

์ƒ๋‹นํžˆ ๊ท€์ฐฎ์€ ๋ฌธ์ œ์˜€๋„ค์š” ,,,,,,,,,,,,,,,,,

์ฝ”๋“œ ์ž˜ ์ฝํžˆ๊ณ  ์ข‹๋„ค์š”,,,

ํ™์ฅฌ๋ฅด ํฌํ’์„ฑ์žฅ ใ…Žใ„ทใ„ทใ„ท

์‹ค๋ฒ„ ๋‹ฌ์„ฑ๋„ ์ถ•ํ•˜๋“œ๋ฆฝ๋‹ˆ๋‹ค...!

Comment on lines +11 to +23
# ์—ด์—์„œ ๋จน์„ ๋•Œ
if data[row][idx] == data[row][idx+1]:
tmp_col += 1
col_cnt = max(col_cnt, tmp_col)
else:
tmp_col = 1

# ํ–‰์—์„œ ๋จน์„ ๋•Œ
if data[idx][col] == data[idx+1][col]:
tmp_row += 1
row_cnt = max(row_cnt, tmp_row)
else:
tmp_row = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ใ…‹ใ…Œใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ "์—ด์—์„œ ๋จน์„ ๋•Œ"

@MunbinLee MunbinLee merged commit 3fe0703 into main May 3, 2024
@MunbinLee MunbinLee deleted the 11-H0ngJu branch May 3, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants