-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path25_A.rs
29 lines (24 loc) · 804 Bytes
/
25_A.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let mut lines = stdin.lock().lines().map(|x| x.unwrap());
let t: usize = lines.next().unwrap().parse().unwrap();
for _ in 0..t {
let n: usize = lines.next().unwrap().parse().unwrap();
let s: String = lines.next().unwrap();
let ones_count = s.chars().filter(|&c| c == '1').count();
if ones_count % 2 == 1 {
println!("NO");
} else {
if ones_count == 2 {
if let Some(first_one) = s.find('1') {
if s.chars().nth(first_one + 1).unwrap() == '1' {
println!("NO");
continue;
}
}
}
println!("YES");
}
}
}