This file contains hidden or 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
| use itertools::Itertools; | |
| fn main() { | |
| proconio::input! { n: i64, b: i64, }; | |
| let mut log10b = 0; | |
| while 10i64.pow(log10b) <= b { log10b += 1; } | |
| let log10b = log10b as usize; | |
| let digits_iter = (0..=9).combinations_with_replacement(log10b); | |
| let mut ans = 0; |
This file contains hidden or 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
| use std::collections::HashMap; | |
| use proconio::{input, marker::Chars}; | |
| const MOD: u32 = 1_000_000_007; | |
| fn main() { | |
| input! { h: usize, w: usize, c: [Chars; h], }; | |
| let mut dp = HashMap::with_capacity(200000); | |
| dp.insert(0u32, 1u32); | |
| for i in 0..h { |
This file contains hidden or 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
| use petgraph::prelude::*; | |
| use petgraph::algo::{min_spanning_tree, connected_components}; | |
| use petgraph::data::FromElements; | |
| fn main() { | |
| proconio::input!{ n: usize, m: usize, clr: [(i64, usize, usize); m], }; | |
| let lrc: Vec<_> = clr.into_iter().map(|(c, l, r)| (l-1, r, c)).collect(); | |
| let g = UnGraph::<(), _, _>::from_edges(&lrc); | |
| if g.node_count() < n+1 || connected_components(&g) > 1 { println!("-1"); return; } | |
| let mst = UnGraph::<_, _>::from_elements(min_spanning_tree(&g)); |
This file contains hidden or 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
| use proconio::{input, fastout, marker::Chars} ; | |
| #[fastout] | |
| fn main() { | |
| input! { | |
| n: usize, | |
| s: Chars, | |
| t: Chars, | |
| }; | |
| let s: Vec<_> = s.into_iter().map(|x| match x {'R'=>0,'G'=>1,'B'=>2,_=>3}).collect(); |
This file contains hidden or 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
| use fixedbitset::FixedBitSet; | |
| use proconio::{input, fastout, marker::Usize1, }; | |
| #[fastout] | |
| fn main() { | |
| input! { | |
| n: usize, m: usize, q: usize, | |
| xy: [(Usize1, Usize1); m], | |
| ab: [(Usize1, Usize1); q], | |
| }; |
This file contains hidden or 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
| const MOD: i128 = 1_000_000_007; | |
| fn main() { | |
| proconio::input!{ l: i128, r: i128, }; | |
| let mut ans = 0; | |
| for i in 0..=18 { | |
| let min = 10i128.pow(i).max(l); | |
| let max = (10i128.pow(i + 1) - 1).min(r); | |
| if min <= max { | |
| ans += (i as i128 + 1) * (min + max) * (max - min + 1) / 2; |
This file contains hidden or 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
| // 位置は0-indexedで表わす。 | |
| // rを固定し、文字列(0,r)の中で'ox'あるいは'xo'が現れる最も右側の位置('ox'なら'x'の位置)をmとすると、 | |
| // oとxを両方含む文字列は、(l,r) = (0,r), (1,r), .., (m-1,r)のm通り。 | |
| // これをr=0, .., n-1について順次加算する。 | |
| fn main() { | |
| proconio::input!{ _n: usize, s: String }; | |
| let mut prev_c = 0; | |
| let mut m = 0; | |
| let mut ans = 0; | |
| for (r, c) in s.bytes().enumerate() { |
This file contains hidden or 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
| use num_integer::{Integer, Roots}; | |
| fn main() { | |
| proconio::input!{abc: i64}; | |
| let mut cnt = 0; | |
| for a in 1..=abc.cbrt() { | |
| if !abc.is_multiple_of(&a) { continue; } | |
| let bc = abc / a; | |
| for b in a..=bc.sqrt() { | |
| if !bc.is_multiple_of(&b) { continue; } |
This file contains hidden or 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
| fn main() { | |
| proconio::input! { | |
| _n: usize, | |
| s: String, | |
| } | |
| let mut cnt: i64 = 0; | |
| for (i, c) in s.chars().enumerate() { | |
| match c { | |
| 'c' => {cnt += 2 << i;}, | |
| 'b' => {cnt += 1 << i;}, |
This file contains hidden or 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
| // https://atcoder.jp/contests/typical90/submissions/24040491 | |
| use proconio::{input, marker::Usize1}; | |
| const MOD: i64 = 1_000_000_007; | |
| fn main() { | |
| input!{ | |
| n: usize, | |
| q: usize, | |
| xyzw: [(Usize1, Usize1, Usize1, u64); q], |