TASTR - Editorial

oops there was a silly mistake, got AC :slight_smile: learnt a lot from this question

@anton_lunyov : sir please help me every time i get a run time error(SIGSEGV)…

http://www.codechef.com/viewsolution/1966634

hello,
could you just tell me weather my code’s output is correct or not, irrespective of time exceed error…

why doesnt work?

module Main where
 
import Data.List
import System.Exit
 
 
al1 xs = nub . concat . map (drop 1 . inits) . tails $ xs
 
cmp xs xz = [ x | x <- ((al1 xs)++(al1 xz)), notElem x (intersect (al1 xs) (al1 xz) )] 
   
 
main = do
    line <- getLine
    line2 <- getLine
    putStr $ show $ length $ cmp line line2
    exitWith ExitSuccess

works fine here runs but (time exceed)
import List
Import System

Might be that we need to find U(A) + U(B) - 2*U(A intersection B) because common substrings appear twice.

This is my code in python. it works fine on my system but dont know why it is not working in codechef

http://ww2.codechef.com/viewsolution/2075046

Probably you misunderstand the idea of contest programming - your code have to return correct answer for each available input, not only the one in problem statement and your program return 8 for each input, simply because you are NOT reading input from stdin…

If U(a) is taken to represent the set of all unique substrings of a, and |U(a)| its size, then the final expression should be: 2*|U(a) UNION U(b)| - |U(a)| - |U(b)|

1 Like

getting run time error NZEC. first submission in codechef. so dont know much abt online compilers. plz help me out sir http://www.codechef.com/viewsolution/5666193

First try to comment System.exit(0); - killing JVM is not a good idea in general…

I’d say, that problem is with memory, you want to allocate array of strings of length n^2 (and n is 100000).

array of strings with no of strings is n2, where n2 being 10 for a four letter word
10=4+3+2+1
so n2=no of letters +(no of letters-1)+…+ 1

and sir system.exit(0) presence or absence has no effect in this case in the runtime error…
any other suggestions sir ?
thanks

Wow… that was a quite a sleek approach… Nice one