結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
fmhr
|
| 提出日時 | 2016-06-25 17:15:13 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 547 bytes |
| コンパイル時間 | 12,267 ms |
| コンパイル使用メモリ | 237,040 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-11 21:59:11 |
| 合計ジャッジ時間 | 13,175 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
var s string
s = readLine()
lenS := len(s)
var wCount, ans int
for i := lenS - 1; i >= 0; i-- {
if s[i] == 'w' {
wCount++
} else if s[i] == 'c' && wCount >= 2 {
ans += wCount * (wCount - 1) / 2
}
}
fmt.Println(ans)
}
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)
func readLine() string {
buf := make([]byte, 0, 1000000)
for {
l, p, e := rdr.ReadLine()
if e != nil {
panic(e)
}
buf = append(buf, l...)
if !p {
break
}
}
return string(buf)
}
fmhr