diff --git a/code_study/Baekjoon/c/4470.c b/code_study/Baekjoon/c/4470.c new file mode 100644 index 0000000..9b54867 --- /dev/null +++ b/code_study/Baekjoon/c/4470.c @@ -0,0 +1,23 @@ +#include +#include + +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; +} \ No newline at end of file diff --git a/code_study/Baekjoon/python/10942.py b/code_study/Baekjoon/python/10942.py new file mode 100644 index 0000000..7d59c40 --- /dev/null +++ b/code_study/Baekjoon/python/10942.py @@ -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)))) \ No newline at end of file