QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457319 | #8832. Daily Disinfection | ucup-team635# | WA | 0ms | 2772kb | Rust | 2.0kb | 2024-06-29 10:29:30 | 2024-06-29 10:29:30 |
Judging History
answer
use std::io::Write;
use std::collections::*;
type Map<K, V> = BTreeMap<K, V>;
type Set<T> = BTreeSet<T>;
type Deque<T> = VecDeque<T>;
fn run() {
input! {
t: usize,
ask: [(usize, bytes); t],
}
let out = std::io::stdout();
let mut out = std::io::BufWriter::new(out.lock());
for (n, s) in ask {
let mut ans = s.iter().filter(|s| **s == b'1').count();
if s[0] == b'1' && s[n - 1] == b'1' {
ans += 1;
}
writeln!(out, "{}", ans).ok();
}
}
fn main() {
run();
}
// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
input_inner!{iter, $($r)*}
};
($($r:tt)*) => {
let s = {
use std::io::Read;
let mut s = String::new();
std::io::stdin().read_to_string(&mut s).unwrap();
s
};
let mut iter = s.split_whitespace();
input_inner!{iter, $($r)*}
};
}
#[macro_export]
macro_rules! input_inner {
($iter:expr) => {};
($iter:expr, ) => {};
($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($iter, $t);
input_inner!{$iter $($r)*}
};
}
#[macro_export]
macro_rules! read_value {
($iter:expr, ( $($t:tt),* )) => {
( $(read_value!($iter, $t)),* )
};
($iter:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
};
($iter:expr, chars) => {
read_value!($iter, String).chars().collect::<Vec<char>>()
};
($iter:expr, bytes) => {
read_value!($iter, String).bytes().collect::<Vec<u8>>()
};
($iter:expr, usize1) => {
read_value!($iter, usize) - 1
};
($iter:expr, $t:ty) => {
$iter.next().unwrap().parse::<$t>().expect("Parse error")
};
}
// ---------- end input macro ----------
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 2116kb
input:
3 2 01 5 00110 9 101010101
output:
1 2 6
result:
ok 3 number(s): "1 2 6"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 2772kb
input:
10000 15 010111111011011 10 1000101111 10 0011111101 1 0 3 110 4 1000 8 10000111 20 00000101000100001110 13 1101110110110 13 0111100011010 17 00001001111110101 1 0 20 10001010011000111100 11 00100110101 11 10110101000 15 001011110011000 16 1110111110000111 15 011110110110010 1 0 20 10110001101100010...
output:
11 7 7 0 2 1 5 6 9 7 9 0 9 5 5 7 12 9 0 10 8 7 3 6 0 6 2 5 4 9 10 4 6 1 8 2 1 8 1 8 12 9 14 4 12 13 16 6 4 4 5 1 1 7 8 5 4 0 0 11 9 5 6 7 6 4 9 1 4 5 12 0 2 10 4 3 7 7 3 7 5 3 7 9 15 2 6 7 9 8 6 1 2 5 2 11 10 5 0 0 4 7 4 8 0 4 7 9 3 3 10 3 6 12 8 1 8 6 5 2 4 9 7 1 6 8 8 3 5 12 6 10 8 8 9 16 2 7 6 4 ...
result:
wrong answer 2nd numbers differ - expected: '6', found: '7'