結果

問題 No.2518 Adjacent Larger
ユーザー ikomaikoma
提出日時 2023-10-27 22:48:50
言語 Rust
(1.77.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,315 bytes
コンパイル時間 1,104 ms
コンパイル使用メモリ 173,684 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-27 22:48:52
合計ジャッジ時間 2,051 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#![allow(unused_imports, dead_code, unused_macros, unused_variables, non_snake_case, unused_parens)]
use std::cmp::{min,max,Ordering,Reverse};
use std::mem::swap;
use std::collections::{VecDeque,LinkedList,HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap};

const YES:&str="Yes";const NO:&str="No";#[inline]fn print_yesno(ans:bool){if ans{println!("{}",YES);}else{println!("{}",NO);}}


fn solve() -> bool {
	let n: usize = {
		let mut line: String = String::new();
		std::io::stdin().read_line(&mut line).unwrap();
		line.trim().parse().unwrap()
	};
	let A: Vec<i64> = {
		let mut line: String = String::new();
		std::io::stdin().read_line(&mut line).unwrap();
		line.split_whitespace()
			.map(|x| x.parse().unwrap())
			.collect()
	};
	let mut n0 = 0;
	let mut n2 = 0;
	let mut flg = 1;
	for i in 0..n {
		if A[i] == 0 {
			n0+=1;
			if i>0 && A[i-1] == 0 || i==0 && A[n-1]==0 {
				return false;
			}
			if flg==0{return false;}
			flg = 0;
		}else if A[i] == 2 {
			n2+=1;
			if i>0 && A[i-1] == 2 || i==0 && A[n-1]==2 {
				return false;
			}
			if flg==2{return false;}
			flg = 2;
		}
	}
	n0 == n2 && n0 > 0
}

fn main() {
	let t: usize = {
		let mut line: String = String::new();
		std::io::stdin().read_line(&mut line).unwrap();
		line.trim().parse().unwrap()
	};
	for _ in 0..t {
		print_yesno(solve());
	}
}
0