This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE NewQualifiedOperators #-} | |
import Prelude | |
import qualified Data.ByteString.Char8 as B | |
import qualified Data.Vector.Unboxed as U | |
import qualified Data.Vector as V | |
import Data.List | |
import Control.Monad | |
import Control.Applicative | |
import Data.Maybe(fromJust) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// solution for CF14 problem B: http://codeforces.com/contest/14/problem/B?locale=en | |
open System | |
let split (s: string) = s.Split([|' '|]) | |
let ints() = [for s in Console.ReadLine() |> split -> int s] | |
let [n;x0] = ints() | |
let segments = [for i in {1..n} -> ints() |> List.sort] | |
let points = x0::(List.concat segments) | |
let okay x = List.forall (fun [a;b]-> a <= x && x <= b) segments | |
let good = List.filter okay points | |
let x = if List.length good = 0 then -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- solution for CF#14 problem A: http://codeforces.com/contest/14/problem/A?locale=en | |
import List | |
import Control.Monad | |
import Control.Applicative | |
solve rows = (reverseCols.cutCols.reverseCols.cutCols.filter notEmpty) rows | |
where reverseCols = map reverse | |
cutCols rows | all ((=='.').head) rows = cutCols $ map tail rows | |
| otherwise = rows | |
notEmpty = any (=='*') |