結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
|
提出日時 | 2022-02-28 14:51:08 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,479 bytes |
コンパイル時間 | 16,203 ms |
コンパイル使用メモリ | 227,420 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 17:11:04 |
合計ジャッジ時間 | 17,062 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 9 |
ソースコード
package main import ( "bufio" "fmt" "math" "os" "strconv" "strings" ) var sc = bufio.NewScanner(os.Stdin) var wr = bufio.NewWriter(os.Stdout) func print(x ...interface{}) { fmt.Fprintln(wr, x...) } func slice_conv(x []int, sep string) string { ret := make([]string, len(x)) for i, v := range x { ret[i] = strconv.Itoa(v) } return strings.Trim(strings.Join(ret, sep), "[]") } func nextString() string { sc.Scan() return sc.Text() } func nextInt() int { sc.Scan() i, err := strconv.Atoi(sc.Text()) if err != nil { panic(err) } return i } func nextFloat() float64 { sc.Scan() i, err := strconv.ParseFloat(sc.Text(), 64) if err != nil { panic(err) } return i } func max(a, b int) int { if a > b { return a } return b } func min(a, b int) int { if a < b { return a } return b } func nmax(a ...int) int { ret := a[0] for _, e := range a { ret = max(ret, e) } return ret } func nmin(a ...int) int { ret := a[0] for _, e := range a { ret = min(ret, e) } return ret } func abs(a int) int { return int(math.Abs(float64(a))) } const ( MOD = 1000000007 INF = 1 << 30 M = 100 ) func modAdd(a *int, b int) { *a += b if *a >= MOD { *a -= MOD } } func main() { defer wr.Flush() sc.Split(bufio.ScanWords) S := nextString() c := 0 w := 0 ans := 0 for _, s := range S { if s == 'w' { w++ } } for _, s := range S { if s == 'c' { c++ } if s == 'w' { w-- ans += c * w } } print(ans) }