Submission #1533976
Source Code Expand
import Data.List main = readLn >>= \n -> fmap (map (read :: String -> Int) . words) getLine >>= \ps -> putStrLn $ tail $ concatMap (\x -> ' ' : show x) $ solve n (zip ps (repeat 0)) solve :: Int -> [(Int,Int)] -> [Int] solve _ [x,y] = [fst x, fst y] solve n ps = x1 : y : solve n qs where (x1,x2) = oddMin ps y = (oddMin' x2 n . tail . dropWhile (\(k1, k2) -> k1 /= x1)) ps p1 = map (\(u,v) -> (u,v-1)) $ takeWhile (\(k1, k2) -> k1 /= x1) ps p2 = dropWhile (\(k1, k2) -> k1 /= x1) ps p2' = takeWhile (\(k1, k2) -> k1 /= y) (tail p2) p3 = map (\(u,v) -> (u,v+1)) $ dropWhile (\(k1, k2) -> k1 /= y) p2 qs = if null p3 then p1 ++ p2' ++ p3 else p1 ++ p2' ++ (tail p3) oddMin :: [(Int,Int)] -> (Int,Int) oddMin xs = minimum $ f xs where f [] = [] f [x] = [x] f (x1:x2:xs) = x1 : f xs oddMin' :: Int -> Int -> [(Int,Int)] -> Int oddMin' k n xs = foldr (\(a1,a2) b -> if a2 == k && a1 < b then a1 else b) n $ f xs where f [] = [] f [x] = [x] f (x1:x2:xs) = x1 : f xs
Submission Info
Submission Time | |
---|---|
Task | E - Young Maids |
User | falke727 |
Language | Haskell (GHC 7.10.3) |
Score | 0 |
Code Size | 1062 Byte |
Status | TLE |
Exec Time | 2123 ms |
Memory | 275836 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 800 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 508 KB |
0_01.txt | AC | 1 ms | 508 KB |
0_02.txt | AC | 1 ms | 508 KB |
1_00.txt | AC | 1 ms | 508 KB |
1_01.txt | AC | 1 ms | 508 KB |
1_02.txt | TLE | 2113 ms | 158076 KB |
1_03.txt | TLE | 2123 ms | 275836 KB |
1_04.txt | TLE | 2107 ms | 91516 KB |
1_05.txt | TLE | 2114 ms | 166268 KB |
1_06.txt | TLE | 2111 ms | 129404 KB |
1_07.txt | TLE | 2116 ms | 204156 KB |
1_08.txt | TLE | 2113 ms | 152956 KB |
1_09.txt | TLE | 2121 ms | 275836 KB |
1_10.txt | TLE | 2107 ms | 91516 KB |
1_11.txt | TLE | 2113 ms | 162556 KB |
1_12.txt | TLE | 2113 ms | 157052 KB |
1_13.txt | TLE | 2114 ms | 156028 KB |
1_14.txt | TLE | 2113 ms | 161148 KB |
1_15.txt | TLE | 2113 ms | 151932 KB |
1_16.txt | TLE | 2113 ms | 166268 KB |
1_17.txt | TLE | 2112 ms | 156028 KB |
1_18.txt | TLE | 2113 ms | 155004 KB |
1_19.txt | TLE | 2114 ms | 149884 KB |