baekjoon 20251222
This commit is contained in:
parent
cb2a409fa9
commit
bf5bc90a57
23
code_study/Baekjoon/c/4470.c
Normal file
23
code_study/Baekjoon/c/4470.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
int N;
|
||||
char str[52];
|
||||
|
||||
scanf("%d",&N);
|
||||
getchar();
|
||||
|
||||
for(int i=1; i<=N; i++) {
|
||||
fgets(str, sizeof(str), stdin);
|
||||
|
||||
// int j = 0;
|
||||
// while(str[j] != '\n' && str[j] != '\0') j++;
|
||||
// if(str[j] == '\n') str[j] = '\0';
|
||||
|
||||
str[strcspn(str, "\n")] = '\0';
|
||||
printf("%d. %s\n",i,str);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
code_study/Baekjoon/python/10942.py
Normal file
20
code_study/Baekjoon/python/10942.py
Normal file
@ -0,0 +1,20 @@
|
||||
import sys
|
||||
input = sys.stdin.readline
|
||||
|
||||
N = int(input())
|
||||
seq = [0] + list(map(int, input().split()))
|
||||
|
||||
dp = [[0]*(N+1) for _ in range(N+1)]
|
||||
for i in range(1,N+1) :
|
||||
dp[i][i] = 1
|
||||
if i != N and seq[i] == seq[i+1] :
|
||||
dp[i][i+1] = 1
|
||||
|
||||
for l in range(3,N+1) :
|
||||
for start in range(1, N - l + 2) :
|
||||
end = start + l - 1
|
||||
if seq[start] == seq[end] and dp[start+1][end-1]:
|
||||
dp[start][end] = 1
|
||||
|
||||
M = int(input())
|
||||
print('\n'.join(list((lambda x: str(dp[x[0]][x[1]]))(list(map(int, input().split()))) for _ in range(M))))
|
||||
Loading…
x
Reference in New Issue
Block a user