結果

問題 No.39 桁の数字を入れ替え
ユーザー vain0vain0
提出日時 2015-07-25 14:10:53
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 7,790 ms
コンパイル使用メモリ 160,404 KB
実行使用メモリ 6,832 KB
最終ジャッジ日時 2023-09-23 04:53:47
合計ジャッジ時間 5,150 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,668 KB
testcase_01 AC 3 ms
6,588 KB
testcase_02 AC 2 ms
6,648 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
6,612 KB
testcase_08 AC 2 ms
6,720 KB
testcase_09 AC 2 ms
6,572 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
6,588 KB
testcase_15 AC 3 ms
6,608 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 3 ms
6,608 KB
testcase_18 AC 2 ms
6,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:9:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in 17 further locations.
    Suggested fix: Please use spaces instead.
  |
9 |         where f(x, xi) (m, mi) = if x > m then (x, xi) else (m, mi)
  | ^^^^^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import qualified Data.Char as Char
import qualified Data.List as List
import Data.Array
import Data.Maybe
import Control.Applicative
import Text.Printf

max_digit xs = foldr1 f (zip xs [0..])
	where f(x, xi) (m, mi) = if x > m then (x, xi) else (m, mi)

swap i j xs =
	map f (zip xs [0..])
	where
		f (x, k)
			| k == i    = xs !! j
			| k == j    = xs !! i
			| otherwise = x

main = do
	ns <- getLine
	let (_, i) = max_digit ns
	let ns' = swap 0 i ns
	putStrLn ns'
0