File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change @@ -177,6 +177,11 @@ executable yosupo-cycle-detection-undirected
177
177
main-is : yosupo-cycle-detection-undirected.hs
178
178
build-depends : verify
179
179
180
+ executable yosupo-deque
181
+ import : app-local
182
+ main-is : yosupo-deque.hs
183
+ build-depends : verify
184
+
180
185
executable yosupo-dynamic-point-set-rectangle-affine-rectangle-sum
181
186
import : app-local
182
187
main-is : yosupo-dynamic-point-set-rectangle-affine-rectangle-sum.hs
You can’t perform that action at this time.
0 commit comments