結果
| 問題 |
No.326 あみだますたー
|
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2017-09-10 15:04:06 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,123 bytes |
| コンパイル時間 | 14,386 ms |
| コンパイル使用メモリ | 446,096 KB |
| 実行使用メモリ | 86,020 KB |
| 最終ジャッジ日時 | 2024-11-20 12:03:25 |
| 合計ジャッジ時間 | 36,850 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 3 WA * 4 MLE * 19 |
コンパイルメッセージ
Main.kt:1:11: warning: parameter 'args' is never used
fun main( args : Array<String> ) {
^
ソースコード
fun main( args : Array<String> ) {
val n = readLine()!!.toInt()
val k = readLine()!!.toInt()
val base = (1..n).map { it }.toMutableList()
(1..k).map {
val swapPoint = readLine()!!.split(" ").first().toInt() - 1
val so = base[swapPoint]
val ta = base[swapPoint+1]
base[swapPoint] = ta
base[swapPoint+1] = so
}
val ans = readLine()!!.split(" ").mapIndexed { i,it ->
Pair(it.toInt(), i )
}
val ansMap = ans.toMap()
// here is 直前
val basePair = base.map {
Pair(it, ansMap[it]!!)
}.toMutableList()
//println( base )
//println( basePair )
val swapPoints = mutableListOf<Int>()
loop@while(true) {
for( i in (0..basePair.size-2) ) {
if( basePair[i].second > basePair[i+1].second ) {
val a1 = basePair[i+1]
val a2 = basePair[i]
basePair[i] = a1
basePair[i+1] = a2
swapPoints.add( i )
}
if( basePair.map { it.second } == basePair.map { it.second }.sortedBy { it } )
break@loop
}
}
//println( basePair )
println( swapPoints.size )
swapPoints.map {
println("${it + 1} ${it + 2}")
}
}
💕💖💞