Skip to content

Instantly share code, notes, and snippets.

@cunitac
cunitac / input.rs
Last active March 7, 2023 04:56
コピペで使える proconio もどき
pub mod input {
use std::cell::RefCell;
use std::fmt::Debug;
use std::io::{stdin, BufRead, BufReader, Stdin};
use std::str::{FromStr, SplitWhitespace};
thread_local!(
pub static STDIN_SOURCE: RefCell<Source> = RefCell::new(Source {
stdin: BufReader::new(stdin()),
tokens: "".split_whitespace(),
});
@cunitac
cunitac / httf2021qual.rs
Created June 30, 2021 06:04
Hack To The Future 2021 予選 の提出コード
use rand::prelude::*;
const N: usize = 20;
const M: usize = 100;
fn main() {
let mut solver = Solver::new();
solver.solve();
solver.out();
}
@cunitac
cunitac / mcts.rs
Created June 30, 2021 05:57
CodinGame Spring Challenge 2021 に提出したソースコードの一部
extern crate anyway_ord;
use {
crate::{command::*, state::*},
anyway_ord::AnywayOrd,
itertools::iproduct,
rand::prelude::*,
std::collections::HashMap,
};
@cunitac
cunitac / bits.rs
Created June 30, 2021 05:56
CodinGame Spring Challenge 2021 に提出したソースコードの一部
use {
crate::{consts::*, info::*},
rand::Rng,
};
pub const NONE: usize = !0;
#[derive(PartialEq, Debug)]
pub struct CellsBits {
pub rich: [u64; 4],
fn main() {
proconio::input!(n: usize, l: u32, k: usize, a: [u32; n]);
let can_get = |score: u32| {
a.iter()
.chain(Some(&l))
.scan((0, 0), |(cum, prev), &a| {
*cum += a - *prev;
*prev = a;
if *cum >= score {