#include <iostream>

using namespace std;

int main(void)
{
	cout << "강한친구 대한육군" << endl;
	cout << "강한친구 대한육군" << endl;
	
	return 0;
}
#include <stdio.h>

int main(void)
{
	int A, B, C = 0;
	
	scanf("%d %d %d", &A, &B, &C);
	
	if (A>=2 and B>=2 and C>=2)
	{
		if (A<=10000 and B<= 10000 and C<= 10000)
		{
			printf("%d\n", (A+B)%C);
			printf("%d\n", ((A%C) + (B%C))%C);
			printf("%d\n", (A*B)%C);
			printf("%d\n", ((A%C)*(B%C))%C);
		}
	}
	
	return 0;
}
#include <iostream>
// 역슬래시 
using namespace std;

int main(void)
{
	cout << "|\\_/|" << endl;
	cout << "|q p|   /}" << endl;
	cout << "( 0 )\"\"\"\\" << endl;
	cout << "|\"^\"`    |" << endl;
	cout << "||_/=\\\\__|" << endl;
}

 

#include <iostream>
// 역슬래시 
using namespace std;

int main(void)
{
	cout << "\\    /\\" << endl;
	cout << " )  ( ')" << endl;
	cout << "(  /  )" << endl;
	cout << " \\(__)|" << endl;
	
	return 0;	
}
# coding:utf-8
def is_adjacent(row):
    for x in range(row):
        # 열이 같음 or 대각선이 같음
        if (queen[x] == queen[row]) or (abs(queen[x] - queen[row]) == abs(row - x)):
            return False
    return True

def dfs(row):
    if row == N:
        global count
        count = count +1
        return 
        
    else:
        for i in range(N):
            queen[row] = i
            if is_adjacent(row):
                dfs(row+1)

if __name__ == "__main__":
    answer = [0, 1, 0, 0, 2, 10, 4, 40, 92, 352, 724, 2680, 14200, 73712, 365596]
    N = int(input())
    queen = [0] * N 
    count = 0
    #dfs(0)
    #print (count)
    print(answer[N])
#include <iostream>

using namespace std;

int main(void)
{
	int score = 0;
	
	cin >> score;
	
	if (score >= 90 and score <=100)
		cout << "A" << endl;
	
	else if(score >=80 and score <=89)
		cout << "B" << endl;
	
	else if(score >=70 and score <=79)
		cout << "C" << endl;
	
	else if(score >=60 and score <=69)
		cout << "D" << endl;
		
	else
		cout << "F" << endl;
		
	return 0;
}
import sys

input = sys.stdin.readline
N = int(input())

for _ in range(N):
    ps = input()
    _sum = 0

    for i in ps:
        if i == "(":
            _sum +=1
        elif i == ")":
            _sum -=1
        
        if _sum < 0:
            break
    
    if _sum == 0:
        print ("YES")

    else:
        print ("NO")
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
	
	int C = 0; // Test case
	int Sum = 0;
	int Weight = 0;
	string S;
	
	cin >> C;
	
	for (int i=0; i<C; i++)
	{
		cin >> S;
		if (S.length()>0 and S.length()<80)
		{
			for (int j=0; j<S.length(); j++)
			{
				if (S[j] == 'O')
				{
					Weight = Weight + 1;
					Sum = Sum + Weight;
				}
				else
					Weight = 0;
			}
			
			cout << Sum << endl;
			Sum = 0;
			Weight = 0;
		}
		

	}

	return 0;
}
#include <stdio.h>

int main(void)

{
	int n = 0;
	int sum = 0;
	
	scanf("%d", &n);
	
	if (n>=1 and n<=10000)
	{
		for (int i=1; i<=n; i++)
		{
			sum = sum + i;
		}
		printf("%d", sum);
	}
	
	return 0;
}
# -*- coding:utf-8 -*-
from collections import deque

def bfs() -> list:
    while queue:
        x, y = queue.popleft()

        for i in range(4):
            a = x + dx[i]
            b = y + dy[i]

            if 0<=a<N and 0<=b<M and graph[a][b] == 0:
                queue.append([a, b]) # 방문하지 않은 다음 노드를 큐에 삽입
                graph[a][b] = graph[x][y] + 1

    return graph

if __name__ == "__main__":

    # 초기 변수 선언 & 그래프 생성
    M, N = list(map(int, input().split()))
    graph = []
    queue = deque()

    dx = [-1, 0, 1, 0] # 익은 토마토 좌표 기준으로 사방향 드로잉을 위한 x좌표
    dy = [0, -1, 0, 1] # 익은 토마토 좌표 기준으로 사방향 드로잉을 위한 y좌표

    for i in range(N):
        graph.append(list(map(int,input().split())))

    # 익은 토마토 좌표 추출 -> 큐 삽입

    for i in range(N):
        for j in range(M):
            if graph[i][j] == 1:
                queue.append([i, j])
    
    # 토마토 숙성
    graph = bfs()

    # 결과 출력
    day = 0
    for i in graph:
        for j in i:
            if j == 0:
                print (-1)
                exit(0)
        day = max(day, max(i))
    
    print (day-1)

+ Recent posts