結果

問題 No.290 1010
ユーザー spacia
提出日時 2016-01-18 23:24:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 616 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 74,600 KB
実行使用メモリ 53,864 KB
最終ジャッジ日時 2024-09-21 07:58:59
合計ジャッジ時間 4,846 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static boolean solve (String s , int n) {
		if (n == 1) return false;
		if (n == 2) return !s.equals("01") && !s.equals("10");
		if (n == 3) return !s.equals("010") && !s.equals("101");
		return true;
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();
		
		out(solve(s , n) ? "YES" : "NO");
	}
	
}
0