Submission #63887539


Source Code Expand

Copy
options(scipen = 100, digits = 10)
conn <- file("stdin", open = "r")
rin <- function(n = 1) readLines(conn, n = n)
split <- function(str, split = " ") unlist(strsplit(str, split = split))
n <- as.integer(rin())
x <- strsplit(rin(), "")[[1L]]
y <- strsplit("atcoder", "")[[1L]]
mod <- 1000000007
dp <- matrix(0L, n + 1L, 8L)
for (i in seq_len(n + 1L)) {
dp[i, 1L] <- 1L
if (i == 1L)
next
for (j in 2L:8L) {
dp[i, j] <- dp[i - 1L, j] +
(if (x[i - 1L] == y[j - 1L]) dp[i - 1L, j - 1L] else 0L)
dp[i, j] <- dp[i, j] %% mod
}
}
cat(dp[n + 1, 8L])
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
options(scipen = 100, digits = 10)
conn <- file("stdin", open = "r")
rin <- function(n = 1) readLines(conn, n = n)
split <- function(str, split = " ") unlist(strsplit(str, split = split))

n <- as.integer(rin())
x <- strsplit(rin(), "")[[1L]]
y <- strsplit("atcoder", "")[[1L]]
mod <- 1000000007
dp <- matrix(0L, n + 1L, 8L)
for (i in seq_len(n + 1L)) {
  dp[i, 1L] <- 1L
  if (i == 1L)
    next
  for (j in 2L:8L) {
    dp[i, j] <- dp[i - 1L, j] +
      (if (x[i - 1L] == y[j - 1L]) dp[i - 1L, j - 1L] else 0L)
    dp[i, j] <- dp[i, j] %% mod
  }
}
cat(dp[n + 1, 8L])

Submission Info

Submission Time
Task 008 - AtCounter(★4)
User negoto_coder
Language R (GNU R 4.2.1)
Score 4
Code Size 590 Byte
Status AC
Exec Time 608 ms
Memory 80380 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 4 / 4
Status
AC × 3
AC × 21
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 10_random_small_00.txt, 10_random_small_01.txt, 11_random_medium_00.txt, 11_random_medium_01.txt, 12_random_large_00.txt, 12_random_large_01.txt, 13_random_max_00.txt, 13_random_max_01.txt, 13_random_max_02.txt, 20_insert_small_00.txt, 20_insert_small_01.txt, 21_insert_medium_00.txt, 21_insert_medium_01.txt, 22_insert_large_00.txt, 22_insert_large_01.txt, 23_insert_max_00.txt, 23_insert_max_01.txt, 23_insert_max_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 130 ms 64612 KB
00_sample_01.txt AC 130 ms 64764 KB
00_sample_02.txt AC 131 ms 65256 KB
10_random_small_00.txt AC 131 ms 64992 KB
10_random_small_01.txt AC 137 ms 67620 KB
11_random_medium_00.txt AC 159 ms 70392 KB
11_random_medium_01.txt AC 202 ms 71392 KB
12_random_large_00.txt AC 369 ms 75052 KB
12_random_large_01.txt AC 450 ms 76976 KB
13_random_max_00.txt AC 606 ms 80004 KB
13_random_max_01.txt AC 602 ms 80372 KB
13_random_max_02.txt AC 603 ms 80272 KB
20_insert_small_00.txt AC 137 ms 67596 KB
20_insert_small_01.txt AC 131 ms 65124 KB
21_insert_medium_00.txt AC 270 ms 72636 KB
21_insert_medium_01.txt AC 363 ms 75088 KB
22_insert_large_00.txt AC 445 ms 77048 KB
22_insert_large_01.txt AC 520 ms 78348 KB
23_insert_max_00.txt AC 605 ms 79960 KB
23_insert_max_01.txt AC 608 ms 80380 KB
23_insert_max_02.txt AC 602 ms 80268 KB


2025-04-04 (Fri)
07:13:36 +00:00