编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#68897 #1001. A. 神秘谜题 Wrong Answer 0 1647 ms 66376 K Haskell / 1.6 K 2n8asm 2022-04-20 16:34:56
import Data.Bits (Bits (shiftL, shiftR, testBit, xor, (.|.)))
import Data.Char (digitToInt)

data Trie = Trie0 | Trie1 | TrieNode Bool Int Trie Trie

instance Show Trie where show = show . trieValue

trieFind :: Trie -> Int
trieFind Trie0 = 0
trieFind Trie1 = 1
trieFind (TrieNode b _ _ _) = fromEnum b

trieInsert :: Trie -> Int -> Trie
trieInsert Trie0 0 = Trie1
trieInsert Trie1 0 = Trie0
trieInsert (TrieNode b i t0 t1) x
  | x == 0 = TrieNode b' i t0 t1
  | testBit x 0 = TrieNode b' i' t0 (trieInsert t1 x')
  | otherwise = TrieNode b' i' (trieInsert t0 x') t1
  where
    b' = not b
    i' = xor i x
    x' = shiftR x 1
trieInsert Trie0 x = trieInsert (TrieNode False 0 Trie0 Trie0) x
trieInsert Trie1 x = trieInsert (TrieNode True 0 Trie1 Trie1) x

trieRead :: Int -> String -> Int
trieRead i [] = i
trieRead i (' ' : s) = trieRead i s
trieRead i ('\r' : s) = trieRead i s
trieRead i (c : s) = trieRead (i * 10 + digitToInt c) s

trieSucc :: Trie -> Trie
trieSucc Trie0 = Trie0
trieSucc Trie1 = TrieNode True 1 Trie0 Trie1
trieSucc (TrieNode b i t0 t1) = TrieNode b i' t1' t0
  where
    i' = shiftL (trieValue t0 `xor` trieValue t1') 1 .|. trieFind t0
    t1' = trieSucc t1

trieValue :: Trie -> Int
trieValue (TrieNode _ i _ _) = i
trieValue _ = 0

trieFoo :: Trie -> String -> Trie
trieFoo trie ('1' : _) = trieSucc trie
trieFoo trie ('2' : x) = trieInsert trie (trieRead 0 x)
trieFoo _ _ = undefined

main :: IO ()
main = do
  n <- getLine
  c <- getContents
  putStr . unlines . map show . tail . scanl trieFoo Trie0 . take (read n) $ lines c
子任务 #1
Wrong Answer
得分:0
测试点 #1
Wrong Answer
得分:0
用时:849 ms
内存:66376 KiB

输入文件(1.in

200000
2 526767110
2 724642759
2 567837900
2 104106873
2 357915481
2 33997211
2 444788944
2 
<1586974 bytes omitted>

答案文件(1.ans

526767110
877985729
361528077
330887284
116239149
82537142
510237286
843295274
453728745
55
<2188330 bytes omitted>

用户输出

526767110
877985729
361528077
330887284
116239149
82537142
510237286
843295274
453728745
559263713
323554710
713540578
520942594
<1988222 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #2
Wrong Answer
得分:0
用时:798 ms
内存:62156 KiB

输入文件(2.in

200000
2 515979308
2 512702340
2 684230440
2 488136957
2 598252313
2 283603971
2 349877373
2
<1586842 bytes omitted>

答案文件(2.ans

515979308
5115816
679905408
899606653
372667236
114362215
302756634
473674072
520218589
525
<2192841 bytes omitted>

用户输出

515979308
5115816
679905408
899606653
372667236
114362215
302756634
473674072
520218589
525056845
703148326
764590712
207056035

<1993117 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0