Skip to content

Commit 5b3a458

Browse files
committed
verify deque
1 parent 53ce43f commit 5b3a458

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

verify/app/yosupo-deque.hs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import AtCoder.Internal.Queue qualified as Q
2+
import Data.Vector.Unboxed qualified as VU
3+
import Util
4+
5+
-- verification-helper: PROBLEM https://judge.yosupo.jp/problem/deque
6+
main :: IO ()
7+
main = do
8+
q <- int
9+
qs <-
10+
VU.replicateM q $
11+
withLine $
12+
intP >>= \case
13+
2 -> pure (2, -1)
14+
3 -> pure (3, -1)
15+
a -> (a,) <$> intP
16+
17+
deq <- Q.newDeque q
18+
res <- (`VU.mapMaybeM` qs) $ \case
19+
(0, !x) -> do
20+
Q.pushFront deq x
21+
pure Nothing
22+
(1, !x) -> do
23+
Q.pushBack deq x
24+
pure Nothing
25+
(2, !_) -> do
26+
Q.popFront_ deq
27+
pure Nothing
28+
(3, !_) -> do
29+
Q.popBack_ deq
30+
pure Nothing
31+
(4, !i) -> do
32+
Just <$> Q.readFront deq i
33+
_ -> error "unreachable"
34+
35+
printBSB $ unlinesBSB res

verify/verify.cabal

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ executable yosupo-cycle-detection-undirected
177177
main-is: yosupo-cycle-detection-undirected.hs
178178
build-depends: verify
179179

180+
executable yosupo-deque
181+
import: app-local
182+
main-is: yosupo-deque.hs
183+
build-depends: verify
184+
180185
executable yosupo-dynamic-point-set-rectangle-affine-rectangle-sum
181186
import: app-local
182187
main-is: yosupo-dynamic-point-set-rectangle-affine-rectangle-sum.hs

0 commit comments

Comments
 (0)