結果

問題 No.346 チワワ数え上げ問題
ユーザー irumo8202irumo8202
提出日時 2022-02-28 14:51:08
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,479 bytes
コンパイル時間 13,099 ms
コンパイル使用メモリ 198,976 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-20 22:24:54
合計ジャッジ時間 14,360 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,336 KB
testcase_01 AC 1 ms
4,328 KB
testcase_02 AC 1 ms
4,332 KB
testcase_03 AC 1 ms
4,332 KB
testcase_04 AC 2 ms
4,328 KB
testcase_05 AC 1 ms
4,328 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,332 KB
testcase_08 AC 1 ms
4,328 KB
testcase_09 AC 1 ms
4,332 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,332 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,328 KB
testcase_14 AC 1 ms
4,332 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,328 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,328 KB
testcase_24 AC 2 ms
4,332 KB
testcase_25 AC 1 ms
4,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
}
0