Submission #44604638


Source Code Expand

Copy
library(stringr)
library(zeallot)
conn <- file("stdin", open="r")
readLine <- function() {
input <- readLines(conn, n=1)
ret <- unlist(strsplit(input, " "))
return(ret)
}
c(N, M) %<-% as.integer(readLine())
S <- readLine()
C <- as.integer(readLine())
A <- array(0, M)
S <- str_split_1(S, "")
for (i in N:1) {
# cat("i=", i, "\n")
color <- C[i]
j <- A[color]
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
library(stringr)
library(zeallot)

conn <- file("stdin", open="r")
readLine <- function() {
    input <- readLines(conn, n=1)
    ret <- unlist(strsplit(input, " "))
    return(ret)
}

c(N, M) %<-% as.integer(readLine())
S <- readLine()
C <- as.integer(readLine())
A <- array(0, M)

S <- str_split_1(S, "")

for (i in N:1) {
    # cat("i=", i, "\n")
    color <- C[i]
    j <- A[color]
    if (j != 0) {
        c(S[i], S[j]) %<-% c(S[j], S[i])
    }
    A[color] <- i
}

S <- str_c(S, collapse="")
cat(S)
cat("\n")

close(conn)

Submission Info

Submission Time
Task C - Rotate Colored Subsequence
User bo9chan
Language R (GNU R 4.2.1)
Score 0
Code Size 559 Byte
Status TLE
Exec Time 2213 ms
Memory 95688 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 6
TLE × 23
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 285 ms 75200 KB
001.txt TLE 2213 ms 95560 KB
002.txt AC 478 ms 91724 KB
003.txt TLE 2213 ms 95536 KB
004.txt TLE 2213 ms 95688 KB
005.txt TLE 2213 ms 95532 KB
006.txt TLE 2213 ms 92644 KB
007.txt AC 770 ms 80040 KB
008.txt TLE 2213 ms 93300 KB
009.txt AC 1378 ms 92708 KB
010.txt TLE 2213 ms 95560 KB
011.txt TLE 2213 ms 95688 KB
012.txt TLE 2212 ms 95536 KB
013.txt TLE 2213 ms 95424 KB
014.txt TLE 2213 ms 95348 KB
015.txt TLE 2213 ms 95444 KB
016.txt TLE 2213 ms 95632 KB
017.txt TLE 2213 ms 95644 KB
018.txt TLE 2213 ms 95420 KB
019.txt TLE 2213 ms 95504 KB
020.txt TLE 2213 ms 95640 KB
021.txt TLE 2213 ms 95488 KB
022.txt TLE 2213 ms 95344 KB
023.txt TLE 2213 ms 95384 KB
024.txt TLE 2213 ms 95372 KB
025.txt TLE 2213 ms 95444 KB
026.txt TLE 2212 ms 95340 KB
example0.txt AC 281 ms 75112 KB
example1.txt AC 286 ms 75320 KB


2025-03-15 (Sat)
06:25:10 +00:00