結果

問題 No.486 3 Straight Win(3連勝)
コンテスト
ユーザー R_F
提出日時 2017-12-03 16:16:41
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 695 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,728 ms
コンパイル使用メモリ 465,976 KB
実行使用メモリ 52,128 KB
最終ジャッジ日時 2026-05-14 15:49:49
合計ジャッジ時間 15,723 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Scanner

data class Count(var eastCount: Int, var westCount: Int)

class No486() {
	val input = Scanner(System. `in`).next()
	val count = Count(0, 0)

	fun victoryOrDefeat(): Count {
		run breaker@ {
			input.forEach {
				if (it == 'O') {
					count.eastCount++
					count.westCount = 0
				} else {
					count.westCount++
					count.eastCount = 0
				}
				if(count.eastCount == 3 || count.westCount == 3) return@breaker
			}
		}
		return count
	}

}

fun main(args: Array<String>) {
	val no486 = No486().victoryOrDefeat()
	var winner = if (no486.eastCount > no486.westCount) "East" else "West"
	if (no486.eastCount < 3 && no486.westCount < 3) winner = "NA"
	println(winner)
}
0