-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add atcoder/abc380/a.rs atcoder/abc380/b.rs atcoder/abc380/c.rs atcod…
…er/abc380/d.rs atcoder/abc380/remain.txt
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn getline() -> String { | ||
let mut ret = String::new(); | ||
std::io::stdin().read_line(&mut ret).ok().unwrap(); | ||
ret | ||
} | ||
|
||
fn main() { | ||
let mut s = getline().trim().bytes().collect::<Vec<_>>(); | ||
s.sort(); | ||
println!("{}", if s == b"122333" { "Yes" } else { "No" }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
fn getline() -> String { | ||
let mut ret = String::new(); | ||
std::io::stdin().read_line(&mut ret).ok().unwrap(); | ||
ret | ||
} | ||
|
||
fn main() { | ||
let s = getline().trim().to_string(); | ||
let a = s.split("|").map(|x| x.len()).collect::<Vec<_>>(); | ||
for &a in &a[1..a.len() - 1] { | ||
print!("{} ", a); | ||
} | ||
println!(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 | ||
macro_rules! input { | ||
($($r:tt)*) => { | ||
let stdin = std::io::stdin(); | ||
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); | ||
let mut next = move || -> String{ | ||
bytes.by_ref().map(|r|r.unwrap() as char) | ||
.skip_while(|c|c.is_whitespace()) | ||
.take_while(|c|!c.is_whitespace()) | ||
.collect() | ||
}; | ||
input_inner!{next, $($r)*} | ||
}; | ||
} | ||
|
||
macro_rules! input_inner { | ||
($next:expr) => {}; | ||
($next:expr,) => {}; | ||
($next:expr, $var:ident : $t:tt $($r:tt)*) => { | ||
let $var = read_value!($next, $t); | ||
input_inner!{$next $($r)*} | ||
}; | ||
} | ||
|
||
macro_rules! read_value { | ||
($next:expr, chars) => { | ||
read_value!($next, String).chars().collect::<Vec<char>>() | ||
}; | ||
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error")); | ||
} | ||
|
||
// Tags: clustering, dedup | ||
fn main() { | ||
input! { | ||
n: usize, k: usize, | ||
s: chars, | ||
} | ||
let mut con = vec![]; | ||
let mut prev = 0; | ||
for i in 0..n { | ||
if s[i] == '1' { | ||
if i > 0 && s[i - 1] == '0' { | ||
prev = i; | ||
} | ||
} else { | ||
if i >= prev + 1 { | ||
con.push((prev, i)); | ||
} | ||
prev = i + 1; | ||
} | ||
} | ||
if s[n - 1] == '1' { | ||
con.push((prev, n)); | ||
} | ||
let mut s = s; | ||
let (_, y) = con[k - 2]; | ||
let (z, w) = con[k - 1]; | ||
for i in z..w { | ||
s.swap(i - z + y, i); | ||
} | ||
println!("{}", s.iter().collect::<String>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use std::io::{Write, BufWriter}; | ||
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 | ||
macro_rules! input { | ||
($($r:tt)*) => { | ||
let stdin = std::io::stdin(); | ||
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); | ||
let mut next = move || -> String{ | ||
bytes.by_ref().map(|r|r.unwrap() as char) | ||
.skip_while(|c|c.is_whitespace()) | ||
.take_while(|c|!c.is_whitespace()) | ||
.collect() | ||
}; | ||
input_inner!{next, $($r)*} | ||
}; | ||
} | ||
|
||
macro_rules! input_inner { | ||
($next:expr) => {}; | ||
($next:expr,) => {}; | ||
($next:expr, $var:ident : $t:tt $($r:tt)*) => { | ||
let $var = read_value!($next, $t); | ||
input_inner!{$next $($r)*} | ||
}; | ||
} | ||
|
||
macro_rules! read_value { | ||
($next:expr, [ $t:tt ; $len:expr ]) => { | ||
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() | ||
}; | ||
($next:expr, chars) => { | ||
read_value!($next, String).chars().collect::<Vec<char>>() | ||
}; | ||
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error")); | ||
} | ||
|
||
fn main() { | ||
let out = std::io::stdout(); | ||
let mut out = BufWriter::new(out.lock()); | ||
macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););} | ||
macro_rules! putvec { | ||
($v:expr) => { | ||
for i in 0..$v.len() { | ||
puts!("{}{}", $v[i], if i + 1 == $v.len() {"\n"} else {" "}); | ||
} | ||
} | ||
} | ||
input! { | ||
s: chars, | ||
q: usize, | ||
k: [i64; q], | ||
} | ||
let mut ans = vec![]; | ||
for k in k { | ||
let k = k - 1; | ||
let q = k / s.len() as i64; | ||
let r = (k % s.len() as i64) as usize; | ||
let mut cur = s[r]; | ||
if q.count_ones() % 2 == 1 { | ||
cur = (cur as u8 ^ 0x20) as char; | ||
} | ||
ans.push(cur); | ||
} | ||
putvec!(ans); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
e | ||
f | ||
g |