結果

問題 No.290 1010
ユーザー startcpp
提出日時 2015-10-16 23:24:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 54,872 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 20:36:48
合計ジャッジ時間 1,361 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

//考察:
//・1文字→NO
//・00または11という部分文字列を含む場合→YES
//・それ以外の場合…101010~または010101~という文字列になる
//→4文字以上ならYES, 3文字以下ならNO

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	static string s;
	cin >> n >> s;
	
	for( int i = 0; i < n - 1; i++ ){
		if( s[i] == s[i + 1] ){
			cout << "YES" << endl;
			return 0;
		}
	}
	if( n >= 4 )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}
0