結果

問題 No.290 1010
ユーザー hama_duhama_du
提出日時 2015-11-22 00:44:00
言語 Go
(1.22.1)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 993 bytes
コンパイル時間 11,366 ms
コンパイル使用メモリ 234,260 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 03:35:45
合計ジャッジ時間 12,232 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main
import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"io"
)

func main() {
	n := nextInt()
	s := nextString(n+10)
	L := -1
	for i := 0 ; i < n-1 ; i++ {
		if s[i] == s[i+1] {
			L = i
			break
		}
	}
	if L == -1 {
		if n <= 3 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	} else {
		fmt.Println("YES")
	}
}

//====

var rdr = bufio.NewReader(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(readToken(20))
	if e != nil {
		panic(e)
	}
	return i
}

func nextString(limit int) string {
	return readToken(limit)
}

func readToken(limit int) string {
	buf := make([]byte, 0, limit)

	for {
		byte, err := rdr.ReadByte()
		if err != nil {
			if err == io.EOF {
				break
			}
		}
		if byte != 10 && byte != 13 && byte != 32 {
			buf = append(buf, byte)
			break
		}
	}
	for {
		byte, err := rdr.ReadByte()
		if err != nil {
			if err == io.EOF {
				break
			}
		}
		if byte == 10 || byte == 13 || byte == 32 {
			break
		}
		buf = append(buf, byte)
	}
	return string(buf)
}
0