結果

問題 No.418 ミンミンゼミ
ユーザー ichibanshiboriichibanshibori
提出日時 2016-09-28 09:57:03
言語 Scala(Beta)
(3.3.1)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 511 bytes
コンパイル時間 5,746 ms
コンパイル使用メモリ 213,176 KB
最終ジャッジ日時 2023-09-12 06:27:54
合計ジャッジ時間 6,281 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
-- Error: Main.scala:24:4 ------------------------------------------------------
24 |	  	println(countAllMatches (minPat) (str))
   |	  	^
   |   Incompatible combinations of tabs and spaces in indentation prefixes.
   |   Previous indent : 2 tabs
   |   Latest indent   : 1 tab, 2 spaces
-- [E006] Not Found Error: Main.scala:23:12 ------------------------------------
23 |		val str = readLine()
   |		          ^^^^^^^^
   |		          Not found: readLine
   |
   | longer explanation available when compiling with `-explain`
2 errors found

ソースコード

diff #

object Main {
	import java.util.regex._
	
	val minPat = Pattern.compile("mi-*n")
	
	def countAllMatches (pat:Pattern) (str:String) = {
		val m = pat.matcher(str)
		
		@scala.annotation.tailrec
		def loop (idx:Int) (result:Int) :Int = {
			if (!m.find(idx)) {
				result
			}else{
				val nextIdx = m.end()
				val nextResult = result + 1
				loop (nextIdx) (nextResult)
			}
		}
		loop (0) (0)
	}
	
	def main(args: Array[String]): Unit = {
		val str = readLine()
	  	println(countAllMatches (minPat) (str))
	}
}
0