結果

問題 No.342 一番ワロタww
ユーザー tsuchinaga
提出日時 2019-03-19 09:29:49
言語 Go
(1.23.4)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 678 bytes
コンパイル時間 14,835 ms
コンパイル使用メモリ 238,884 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 12:12:21
合計ジャッジ時間 11,804 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var s, t string
	var w int

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	sc.Scan()
	s = sc.Text()

	max := 1
	ans := make([]string, 0)
	for _, r := range []rune(s) {
		if string(r) == "w" {
			w++
		} else {
			if w != 0 {
				if max < w && t != "" {
					ans = []string{t}
					max = w
				} else if max == w && t != "" {
					ans = append(ans, t)
				}

				t = ""
				w = 0
			}
			t += string(r)
		}
	}

	if max < w && t != "" {
		ans = []string{t}
		max = w
	} else if max == w && t != "" {
		ans = append(ans, t)
	}

	// fmt.Println(ans)

	for _, str := range ans {
		fmt.Println(str)
	}
}
0