Baekjoon-10942-팰린드롬?
03 Oct 2022import sys
from math import factorial as fac
input = sys.stdin.readline
N = int(input())
arr = list(map(int, input().split()))
dp = [[0] * N for _ in range(N)]
for i in range(N):
dp[i][i] = 1
if i != N-1:
dp[i+1][i] = 1
for i in range(1,N):
for j in range(N-i):
dp[j][j+i] = 1 if arr[j]==arr[j+i] and dp[j+1][j+i-1]==1 else 0
# print result
M = int(input())
result = []
for _ in range(M):
S,E = map(int, input().split())
result.append(dp[S-1][E-1])
for r in result:
print(r)