# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1129191 | mnbvcxz123 | Klavir (COCI17_klavir) | C++20 | 161 ms | 22020 KiB |
#include <stdio.h>
#define N 1000000
#define MD 1000000007
int main() {
static int aa[N], ff[N + 1], dp[N + 1];
int n, m, i, j;
scanf("%d%d", &m, &n);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
ff[0] = -1, ff[1] = 0;
for (i = -1, j = 0; j < n; i++, j++) {
while (i >= 0 && aa[i] != aa[j])
i = ff[i];
ff[j + 1] = i + 1;
dp[j + 1] = j == 0 ? m : ((long long) (dp[j] - dp[ff[j]] + MD) * m + dp[i + 1]) % MD;
printf("%d\n", dp[j + 1]);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |