結果
| 問題 |
No.26 シャッフルゲーム
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2014-11-16 20:54:20 |
| 言語 | Haskell (9.10.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 599 bytes |
| コンパイル時間 | 6,816 ms |
| コンパイル使用メモリ | 174,464 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-31 21:10:04 |
| 合計ジャッジ時間 | 7,199 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 6 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Control.Applicative
import Control.Monad
import Data.Bits
readInts :: IO [Int]
readInts = map read . words <$> getLine
rightmost :: Int -> Int
rightmost n = length $ takeWhile (not . testBit n) [0..31]
swap :: Int -> Int -> Int -> Int
swap x n m = x `xor` a `xor` shift a d
where
d = m-n
a = shift x (-d) `xor` x .&. shift 1 n
main = do
n <- readLn
m <- readLn
query <- replicateM m readInts
let
query' = map (map (subtract 1)) query
f [] s = 1 + rightmost s
f ([p,q]:rs) s = f rs (swap s p q)
in print $ f query' (shift 1 (n-1))
tottoripaper