Skip to content

Instantly share code, notes, and snippets.

@kngwyu
Created June 2, 2016 15:42
Show Gist options
  • Save kngwyu/04f285712009470d3949d9ebafa1b6a0 to your computer and use it in GitHub Desktop.
Save kngwyu/04f285712009470d3949d9ebafa1b6a0 to your computer and use it in GitHub Desktop.
fn main() {
let input = getvec();
let n = input[0];
let q = input[1];
let ns = n as usize;
let mut imos = vec![0; ns];
for _ in 0..q {
let temp = getvec();
let s = temp[0] as usize;
let g = temp[1] as usize;
imos[s - 1] += 1;
if g != ns { imos[g] -= 1;}
}
for i in 1..imos.len() {
imos[i] += imos[i - 1];
}
for x in imos {
let a = if x < 0 {-1 * x} else {x};
print!("{}", a % 2);
}
print!("\n");
}
fn next_line() -> String {
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
input
}
/*fn getint() -> i32 {
let res = next_line();
let res = res.trim().parse().unwrap();
res
}*/
fn getvec() -> Vec<i32> {
let res = next_line();
let res : Vec<i32> = res.split_whitespace().map(|x| x.parse().unwrap()).collect();
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment