結果
| 問題 |
No.587 七対子
|
| コンテスト | |
| ユーザー |
R_F
|
| 提出日時 | 2017-11-28 00:38:42 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,185 bytes |
| コンパイル時間 | 15,114 ms |
| コンパイル使用メモリ | 436,080 KB |
| 実行使用メモリ | 57,960 KB |
| 最終ジャッジ日時 | 2024-11-20 13:18:15 |
| 合計ジャッジ時間 | 27,125 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 WA * 10 |
コンパイルメッセージ
Main.kt:39:10: warning: parameter 'args' is never used
fun main(args: Array<String>){
^
ソースコード
import java.util.Scanner
fun duplication(input: List<String>): MutableList<String>{
var list: MutableList<String> = mutableListOf()
for(i in 0..input.count() - 2){
if( !(input[i] in list) ) list.add(input[i])
}
return list
}
fun charaCount(input: List<String>, duplicationList: MutableList<String>): MutableList<Int>{
var countList: MutableList<Int> = mutableListOf()
for(item in duplicationList){
var count: Int = 0
for(i in 0..input.count() - 2){
if(item == input[i]) count++
}
countList.add(count)
}
return countList
}
fun run(duplicationList: MutableList<String>, countList: MutableList<Int>){
var flag: Boolean = false
var result: MutableList<String> = mutableListOf()
for(i in 0..countList.count() - 1){
if(countList[i] > 2){
flag = false
break
} else if(countList[i] == 1){
result.add(duplicationList[i])
flag = true
}
}
if(flag == true && result.count() == 1) println(result[0])
else println("Impossible")
}
fun main(args: Array<String>){
var input = (Scanner(System. `in`).next()).split(Regex(""))
var duplicationList = duplication(input)
var countList = charaCount(input, duplicationList)
run(duplicationList, countList)
}
R_F