結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2016-06-25 17:16:53 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 11,599 ms |
コンパイル使用メモリ | 222,428 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 21:59:30 |
合計ジャッジ時間 | 12,618 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 wCount >= 2 && s[i] == 'c' { 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) }