Submission #47295075
Source Code Expand
{-# OPTIONS_GHC -O2 #-}
-- copy of #32837196
module Main where
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Algorithms.Intro as VAI
{-# RULES "Force inline VAI.sort" VAI.sort = VAI.sortBy compare #-}
main :: IO ()
main = do
getLine
zs <- map (map read . words) . lines <$> getContents
print $ solve zs
solve :: [[Double]] -> Double
solve zs = answer
where
zs' = VU.fromList $ map (\[x, y] -> (x, y)) zs
answer = VU.maximum $ VU.map (calc zs') zs'
calc :: VU.Vector (Double, Double) -> (Double, Double) -> Double
calc zs z@(x, y) = inner 0.0 0 0
where
zs' = VU.modify VAI.sort . VU.map angle . VU.filter (/= z) $ zs
len = VU.length zs'
angle (x', y') = atan2 (y' - y) (x' - x) * 180.0 / pi
inner s i j
| i == len || j == 2 * len = s
| a == b = inner s i (j + 1)
| c <= 180.0 = inner (max s c) i (j + 1)
| otherwise = inner (max s (360.0 - c)) (i + 1) j
where
a = zs' VU.! i
b = if j < len then zs' VU.! j else zs' VU.! (j - len)
c = b - a + if b > a then 0.0 else 360.0
Submission Info
| Submission Time | |
|---|---|
| Task | 009 - Three Point Angle(★6) |
| User | gksato |
| Language | Haskell (GHC 9.4.5) |
| Score | 6 |
| Code Size | 1145 Byte |
| Status | AC |
| Exec Time | 411 ms |
| Memory | 12804 KiB |
Compile Error
app/Main.hs:7:1: warning: [-Wunused-imports]
The import of ‘Data.List’ is redundant
except perhaps to import instances from ‘Data.List’
To import instances alone, use: import Data.List()
|
7 | import Data.List
| ^^^^^^^^^^^^^^^^
app/Main.hs:10:11: warning: [-Worphans]
Orphan rule: "Force inline VAI.sort"
forall (@(v :: * -> * -> *))
(@(m :: * -> *))
(@e)
($dPrimMonad_a23j :: Control.Monad.Primitive.PrimMonad m)
($dMVector_a23k :: Data.Vector.Generic.Mutable.Base.MVector v e)
($dOrd_a23l :: Ord e).
VAI.sort @m @v @e $dPrimMonad_a23j $dMVector_a23k $dOrd_a23l
= VAI.sortBy
@m @v @e $dPrimMonad_a23j $dMVector_a23k (compare @e $dOrd_a23l)
|
10 | {-# RULES "Force inline VAI.sort" VAI.sort = VAI.sortBy compare #-}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:14:3: warning: [-Wunused-do-bind]
A do-notation statement discarded a result of type ‘String’
Suggested fix: Suppress this warning by saying ‘_ <- getLine’
|
14 | getLine
| ^^^^^^^
app/Main.hs:21:30: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a lambda abstraction:
Patterns of type ‘[Double]’ not matched:
[]
[_]
(_:_:_:_)
|
21 | zs' = VU.fromList $ map (\[x, y] -> (x, y)) zs
| ^^^^^^^^^^^^^^^^^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 6 / 6 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | Sample_1.txt, Sample_2.txt, Sample_3.txt, Sample_4.txt |
| All | Random_1.txt, Random_2.txt, Random_3.txt, Random_4.txt, Random_5.txt, Random_6.txt, Random_7.txt, Random_8.txt, Regular_Polygon_1.txt, Regular_Polygon_2.txt, Regular_Polygon_3.txt, Regular_Polygon_4.txt, Regular_Polygon_5.txt, Regular_Polygon_6.txt, Regular_Polygon_7.txt, Regular_Polygon_8.txt, Sample_1.txt, Sample_2.txt, Sample_3.txt, Sample_4.txt, Small_1.txt, Small_2.txt, Small_3.txt, Small_4.txt, Small_5.txt, Small_6.txt, Small_7.txt, Small_8.txt, Three_Linear_1.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| Random_1.txt | AC | 21 ms | 11876 KiB |
| Random_2.txt | AC | 201 ms | 12296 KiB |
| Random_3.txt | AC | 41 ms | 12340 KiB |
| Random_4.txt | AC | 71 ms | 12344 KiB |
| Random_5.txt | AC | 171 ms | 12356 KiB |
| Random_6.txt | AC | 41 ms | 12352 KiB |
| Random_7.txt | AC | 301 ms | 12440 KiB |
| Random_8.txt | AC | 411 ms | 12344 KiB |
| Regular_Polygon_1.txt | AC | 2 ms | 7576 KiB |
| Regular_Polygon_2.txt | AC | 2 ms | 7624 KiB |
| Regular_Polygon_3.txt | AC | 101 ms | 12572 KiB |
| Regular_Polygon_4.txt | AC | 101 ms | 12348 KiB |
| Regular_Polygon_5.txt | AC | 61 ms | 12452 KiB |
| Regular_Polygon_6.txt | AC | 191 ms | 12772 KiB |
| Regular_Polygon_7.txt | AC | 111 ms | 12512 KiB |
| Regular_Polygon_8.txt | AC | 221 ms | 12804 KiB |
| Sample_1.txt | AC | 2 ms | 7684 KiB |
| Sample_2.txt | AC | 2 ms | 7748 KiB |
| Sample_3.txt | AC | 2 ms | 7808 KiB |
| Sample_4.txt | AC | 2 ms | 8732 KiB |
| Small_1.txt | AC | 2 ms | 7820 KiB |
| Small_2.txt | AC | 2 ms | 7892 KiB |
| Small_3.txt | AC | 2 ms | 7796 KiB |
| Small_4.txt | AC | 2 ms | 7784 KiB |
| Small_5.txt | AC | 2 ms | 7940 KiB |
| Small_6.txt | AC | 2 ms | 7744 KiB |
| Small_7.txt | AC | 2 ms | 7796 KiB |
| Small_8.txt | AC | 2 ms | 7844 KiB |
| Three_Linear_1.txt | AC | 2 ms | 7708 KiB |