-
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/abc298/a.rs atcoder/abc298/b.rs atcoder/abc298/c.rs atcod…
…er/abc298/d.rs atcoder/abc298/e.rs atcoder/abc298/remain.txt atcoder/abc305/a.rs atcoder/abc305/b.rs atcoder/abc305/c.rs atcoder/abc305/d.rs atcoder/abc305/remain.txt atcoder/abc311/a.rs atcoder/abc311/b.rs atcoder/abc311/remain.txt atcoder/abc315/a.rs atcoder/abc315/b.rs atcoder/abc315/c.rs atcoder/abc315/remain.txt atcoder/abc318/a.rs atcoder/abc318/remain.txt atcoder/abc321/a.rs atcoder/abc321/remain.txt atcoder/abc323/a.rs atcoder/abc323/remain.txt
- Loading branch information
Showing
24 changed files
with
807 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,20 @@ | ||
fn getline() -> String { | ||
let mut ret = String::new(); | ||
std::io::stdin().read_line(&mut ret).ok().unwrap(); | ||
ret | ||
} | ||
|
||
fn main() { | ||
getline(); | ||
let mut good = 0; | ||
let mut bad = 0; | ||
for c in getline().trim().chars() { | ||
if c == 'o' { | ||
good += 1; | ||
} | ||
if c == 'x' { | ||
bad += 1; | ||
} | ||
} | ||
println!("{}", if good > 0 && bad == 0 { "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,66 @@ | ||
// 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, $t:ty) => ($next().parse::<$t>().expect("Parse error")); | ||
} | ||
|
||
fn rot(a: Vec<Vec<i32>>) -> Vec<Vec<i32>> { | ||
let n = a.len(); | ||
let mut b = vec![vec![0; n]; n]; | ||
for i in 0..n { | ||
for j in 0..n { | ||
b[i][j] = a[n - 1 - j][i]; | ||
} | ||
} | ||
b | ||
} | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [[i32; n]; n], | ||
b: [[i32; n]; n], | ||
} | ||
let mut a = a; | ||
for _ in 0..4 { | ||
let mut ok = true; | ||
for i in 0..n { | ||
for j in 0..n { | ||
if a[i][j] == 1 && b[i][j] == 0 { | ||
ok = false; | ||
} | ||
} | ||
} | ||
if ok { | ||
println!("Yes"); | ||
return; | ||
} | ||
a = rot(a); | ||
} | ||
println!("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,54 @@ | ||
use std::collections::*; | ||
use std::io::Read; | ||
|
||
fn get_word() -> String { | ||
let stdin = std::io::stdin(); | ||
let mut stdin=stdin.lock(); | ||
let mut u8b: [u8; 1] = [0]; | ||
loop { | ||
let mut buf: Vec<u8> = Vec::with_capacity(16); | ||
loop { | ||
let res = stdin.read(&mut u8b); | ||
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { | ||
break; | ||
} else { | ||
buf.push(u8b[0]); | ||
} | ||
} | ||
if buf.len() >= 1 { | ||
let ret = String::from_utf8(buf).unwrap(); | ||
return ret; | ||
} | ||
} | ||
} | ||
|
||
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } | ||
|
||
fn main() { | ||
let n: usize = get(); | ||
let q: usize = get(); | ||
let mut bx = vec![vec![]; n]; | ||
let mut inv = vec![BTreeSet::new(); 200_100]; | ||
for _ in 0..q { | ||
let ty: i32 = get(); | ||
let i: usize = get(); | ||
if ty == 1 { | ||
let j: usize = get(); | ||
bx[j - 1].push(i); | ||
inv[i - 1].insert(j); | ||
continue; | ||
} | ||
if ty == 2 { | ||
bx[i - 1].sort_unstable(); | ||
for &v in &bx[i - 1] { | ||
print!("{} ", v); | ||
} | ||
println!(); | ||
continue; | ||
} | ||
for &v in inv[i - 1].iter() { | ||
print!("{} ", v); | ||
} | ||
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,53 @@ | ||
use std::collections::*; | ||
use std::io::Read; | ||
|
||
fn get_word() -> String { | ||
let stdin = std::io::stdin(); | ||
let mut stdin=stdin.lock(); | ||
let mut u8b: [u8; 1] = [0]; | ||
loop { | ||
let mut buf: Vec<u8> = Vec::with_capacity(16); | ||
loop { | ||
let res = stdin.read(&mut u8b); | ||
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { | ||
break; | ||
} else { | ||
buf.push(u8b[0]); | ||
} | ||
} | ||
if buf.len() >= 1 { | ||
let ret = String::from_utf8(buf).unwrap(); | ||
return ret; | ||
} | ||
} | ||
} | ||
|
||
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } | ||
|
||
const MOD: i64 = 998_244_353; | ||
|
||
fn main() { | ||
let q: usize = get(); | ||
let mut que = VecDeque::new(); | ||
que.push_back(1); | ||
let mut val = 1; | ||
let inv10 = (3 * MOD + 1) / 10; | ||
let mut cur = 10; | ||
for _ in 0..q { | ||
let ty: i32 = get(); | ||
if ty == 1 { | ||
let x: i64 = get(); | ||
que.push_back(x); | ||
val = (10 * val + x) % MOD; | ||
cur = cur * 10 % MOD; | ||
continue; | ||
} | ||
if ty == 2 { | ||
let t = que.pop_front().unwrap(); | ||
cur = cur * inv10 % MOD; | ||
val = (val + MOD - t * cur % MOD) % MOD; | ||
continue; | ||
} | ||
println!("{}", val); | ||
} | ||
} |
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,144 @@ | ||
use std::io::Read; | ||
|
||
fn get_word() -> String { | ||
let stdin = std::io::stdin(); | ||
let mut stdin=stdin.lock(); | ||
let mut u8b: [u8; 1] = [0]; | ||
loop { | ||
let mut buf: Vec<u8> = Vec::with_capacity(16); | ||
loop { | ||
let res = stdin.read(&mut u8b); | ||
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { | ||
break; | ||
} else { | ||
buf.push(u8b[0]); | ||
} | ||
} | ||
if buf.len() >= 1 { | ||
let ret = String::from_utf8(buf).unwrap(); | ||
return ret; | ||
} | ||
} | ||
} | ||
|
||
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } | ||
|
||
/// Verified by https://atcoder.jp/contests/abc198/submissions/21774342 | ||
mod mod_int { | ||
use std::ops::*; | ||
pub trait Mod: Copy { fn m() -> i64; } | ||
#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct ModInt<M> { pub x: i64, phantom: ::std::marker::PhantomData<M> } | ||
impl<M: Mod> ModInt<M> { | ||
// x >= 0 | ||
pub fn new(x: i64) -> Self { ModInt::new_internal(x % M::m()) } | ||
fn new_internal(x: i64) -> Self { | ||
ModInt { x: x, phantom: ::std::marker::PhantomData } | ||
} | ||
pub fn pow(self, mut e: i64) -> Self { | ||
debug_assert!(e >= 0); | ||
let mut sum = ModInt::new_internal(1); | ||
let mut cur = self; | ||
while e > 0 { | ||
if e % 2 != 0 { sum *= cur; } | ||
cur *= cur; | ||
e /= 2; | ||
} | ||
sum | ||
} | ||
#[allow(dead_code)] | ||
pub fn inv(self) -> Self { self.pow(M::m() - 2) } | ||
} | ||
impl<M: Mod> Default for ModInt<M> { | ||
fn default() -> Self { Self::new_internal(0) } | ||
} | ||
impl<M: Mod, T: Into<ModInt<M>>> Add<T> for ModInt<M> { | ||
type Output = Self; | ||
fn add(self, other: T) -> Self { | ||
let other = other.into(); | ||
let mut sum = self.x + other.x; | ||
if sum >= M::m() { sum -= M::m(); } | ||
ModInt::new_internal(sum) | ||
} | ||
} | ||
impl<M: Mod, T: Into<ModInt<M>>> Sub<T> for ModInt<M> { | ||
type Output = Self; | ||
fn sub(self, other: T) -> Self { | ||
let other = other.into(); | ||
let mut sum = self.x - other.x; | ||
if sum < 0 { sum += M::m(); } | ||
ModInt::new_internal(sum) | ||
} | ||
} | ||
impl<M: Mod, T: Into<ModInt<M>>> Mul<T> for ModInt<M> { | ||
type Output = Self; | ||
fn mul(self, other: T) -> Self { ModInt::new(self.x * other.into().x % M::m()) } | ||
} | ||
impl<M: Mod, T: Into<ModInt<M>>> AddAssign<T> for ModInt<M> { | ||
fn add_assign(&mut self, other: T) { *self = *self + other; } | ||
} | ||
impl<M: Mod, T: Into<ModInt<M>>> SubAssign<T> for ModInt<M> { | ||
fn sub_assign(&mut self, other: T) { *self = *self - other; } | ||
} | ||
impl<M: Mod, T: Into<ModInt<M>>> MulAssign<T> for ModInt<M> { | ||
fn mul_assign(&mut self, other: T) { *self = *self * other; } | ||
} | ||
impl<M: Mod> Neg for ModInt<M> { | ||
type Output = Self; | ||
fn neg(self) -> Self { ModInt::new(0) - self } | ||
} | ||
impl<M> ::std::fmt::Display for ModInt<M> { | ||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { | ||
self.x.fmt(f) | ||
} | ||
} | ||
impl<M: Mod> From<i64> for ModInt<M> { | ||
fn from(x: i64) -> Self { Self::new(x) } | ||
} | ||
} // mod mod_int | ||
|
||
macro_rules! define_mod { | ||
($struct_name: ident, $modulo: expr) => { | ||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
struct $struct_name {} | ||
impl mod_int::Mod for $struct_name { fn m() -> i64 { $modulo } } | ||
} | ||
} | ||
const MOD: i64 = 998_244_353; | ||
define_mod!(P, MOD); | ||
type MInt = mod_int::ModInt<P>; | ||
|
||
fn main() { | ||
let n: usize = get(); | ||
let a: usize = get(); | ||
let b: usize = get(); | ||
let p: i64 = get(); | ||
let q: i64 = get(); | ||
let invp = MInt::new(p).inv(); | ||
let invq = MInt::new(q).inv(); | ||
let mut dp = vec![vec![MInt::new(0); n]; n]; | ||
let mut ep = vec![vec![MInt::new(0); n]; n]; | ||
for s in (0..2 * n - 1).rev() { | ||
for i in 0..s + 1 { | ||
let j = s - i; | ||
if i >= n || j >= n { continue; } | ||
let mut tmp = MInt::new(0); | ||
for x in 1..p as usize + 1 { | ||
if i + x >= n { | ||
tmp += 1; | ||
} else { | ||
tmp += ep[i + x][j]; | ||
} | ||
} | ||
dp[i][j] = tmp * invp; | ||
let mut tmp = MInt::new(0); | ||
for x in 1..q as usize + 1 { | ||
if j + x < n { | ||
tmp += dp[i][j + x]; | ||
} | ||
} | ||
ep[i][j] = tmp * invq; | ||
} | ||
} | ||
println!("{}", dp[a][b]); | ||
} |
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 @@ | ||
f | ||
g | ||
ex |
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,29 @@ | ||
use std::io::Read; | ||
|
||
fn get_word() -> String { | ||
let stdin = std::io::stdin(); | ||
let mut stdin=stdin.lock(); | ||
let mut u8b: [u8; 1] = [0]; | ||
loop { | ||
let mut buf: Vec<u8> = Vec::with_capacity(16); | ||
loop { | ||
let res = stdin.read(&mut u8b); | ||
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { | ||
break; | ||
} else { | ||
buf.push(u8b[0]); | ||
} | ||
} | ||
if buf.len() >= 1 { | ||
let ret = String::from_utf8(buf).unwrap(); | ||
return ret; | ||
} | ||
} | ||
} | ||
|
||
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } | ||
|
||
fn main() { | ||
let n: i32 = get(); | ||
println!("{}", (2 * n + 5) / 10 * 5); | ||
} |
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,16 @@ | ||
fn getline() -> String { | ||
let mut ret = String::new(); | ||
std::io::stdin().read_line(&mut ret).ok().unwrap(); | ||
ret | ||
} | ||
|
||
fn main() { | ||
let s: Vec<_> = getline().bytes().collect(); | ||
let mut x = (s[0] - b'A') as usize; | ||
let mut y = (s[2] - b'A') as usize; | ||
if x > y { | ||
std::mem::swap(&mut x, &mut y); | ||
} | ||
let a = [3, 1, 4, 1, 5, 9]; | ||
println!("{}", a[x..y].iter().sum::<i32>()); | ||
} |
Oops, something went wrong.