Skip to content

Final crate update #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .cargo/config
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[alias]
dep-tests = ["run", "--manifest-path", "./tools/dep-tests/Cargo.toml", "--"]
test-examples = ["run", "--manifest-path", "./tools/test-examples/Cargo.toml", "--"]
138 changes: 30 additions & 108 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -14,17 +14,17 @@ jobs:
# Breaking changes like this might be mixed into the future stable versions.
# https://github.com/rust-lang/rustfmt/pull/3632
channel:
- 1.39.0
- 1.40.0
- stable

name: Rustfmt (${{ matrix.channel }})
runs-on: ubuntu-18.04

steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: rust-toolchain
- name: Setup ${{ matrix.channel }}-x86_64-unknown-linux-gnu
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.channel }}-x86_64-unknown-linux-gnu
@@ -37,71 +37,22 @@ jobs:
command: fmt
args: -- --check

- name: '`cargo fmt --manifest-path ./tools/dep-tests/Cargo.toml -- --check`'
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ./tools/dep-tests/Cargo.toml -- --check

- name: '`cargo fmt --manifest-path ./tools/test-examples/Cargo.toml -- --check`'
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ./tools/test-examples/Cargo.toml -- --check

test-examples:
name: test-examples
runs-on: ubuntu-18.04

steps:
- name: Checkout
uses: actions/checkout@v1

- name: setup-python
uses: actions/setup-python@v1
with:
python-version: '3.8'

- name: rust-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.39.0-x86_64-unknown-linux-gnu
default: true
profile: default

- name: '`cargo install --git https://github.com/rust-lang-ja/atcoder-rustc-dep-option-generator`'
uses: actions-rs/cargo@v1
with:
command: install
args: --git https://github.com/rust-lang-ja/atcoder-rustc-dep-option-generator

- name: '`cargo clippy --all-features --manifest-path ./tools/test-examples/Cargo.toml -- -D warnings`'
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --manifest-path ./tools/test-examples/Cargo.toml -- -D warnings

- name: '`cargo build --all-features --release`'
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --release

- name: '`cargo test-examples`'
uses: actions-rs/cargo@v1
with:
command: test-examples

build:
strategy:
fail-fast: false
matrix:
toolchain:
# `x86_64-pc-windows-gnu` is tier 1 **for now**.
- 1.39.0-x86_64-pc-windows-msvc
- 1.39.0-x86_64-pc-windows-gnu
- 1.39.0-x86_64-apple-darwin
- 1.39.0-x86_64-unknown-linux-gnu
- 1.40.0-x86_64-pc-windows-msvc
- 1.40.0-x86_64-pc-windows-gnu
- 1.40.0-x86_64-apple-darwin
- 1.40.0-x86_64-unknown-linux-gnu
- stable-x86_64-pc-windows-msvc
- stable-x86_64-pc-windows-gnu
- stable-x86_64-apple-darwin
@@ -111,53 +62,29 @@ jobs:
- beta-x86_64-apple-darwin
- beta-x86_64-unknown-linux-gnu
include:
- toolchain: 1.39.0-x86_64-pc-windows-msvc
features: --no-default-features
dep_tests: true
- toolchain: 1.40.0-x86_64-pc-windows-msvc
os: windows-latest
- toolchain: 1.39.0-x86_64-pc-windows-gnu
features: --no-default-features
dep_tests: false
- toolchain: 1.40.0-x86_64-pc-windows-gnu
os: windows-latest
- toolchain: 1.39.0-x86_64-apple-darwin
features: --all-features
dep_tests: true
- toolchain: 1.40.0-x86_64-apple-darwin
os: macOS-latest
- toolchain: 1.39.0-x86_64-unknown-linux-gnu
features: --all-features
dep_tests: true
- toolchain: 1.40.0-x86_64-unknown-linux-gnu
os: ubuntu-18.04
- toolchain: stable-x86_64-pc-windows-msvc
features: --no-default-features
dep_tests: true
os: windows-latest
- toolchain: stable-x86_64-pc-windows-gnu
features: --no-default-features
dep_tests: false
os: windows-latest
- toolchain: stable-x86_64-apple-darwin
features: --all-features
dep_tests: true
os: macOS-latest
- toolchain: stable-x86_64-unknown-linux-gnu
features: --all-features
dep_tests: true
os: ubuntu-18.04
- toolchain: beta-x86_64-pc-windows-msvc
features: --no-default-features
dep_tests: true
os: windows-latest
- toolchain: beta-x86_64-pc-windows-gnu
features: --no-default-features
dep_tests: false
os: windows-latest
- toolchain: beta-x86_64-apple-darwin
features: --all-features
dep_tests: true
os: macOS-latest
- toolchain: beta-x86_64-unknown-linux-gnu
features: --all-features
dep_tests: true
os: ubuntu-18.04

name: ${{ matrix.toolchain }}
@@ -169,50 +96,45 @@ jobs:
if: matrix.os == 'windows-latest'

- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: rust-toolchain
- name: Setup ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
profile: default

- name: '`cargo clippy --all-targets --profile test ${{ matrix.features }} -- -D warnings`'
uses: actions-rs/cargo@v1
- name: Setup Python 3.8
uses: actions/setup-python@v1
with:
command: clippy
args: --all-targets --profile test ${{ matrix.features }} -- -D warnings
python-version: '3.8'

- name: '`cargo test --all-targets ${{ matrix.features }} --no-fail-fast`'
- name: '`cargo clippy --all-targets --profile test -- -D warnings`'
uses: actions-rs/cargo@v1
with:
command: test
args: --all-targets ${{ matrix.features }} --no-fail-fast
command: clippy
args: --all-targets --profile test -- -D warnings

- name: '`cargo run --release`'
- name: '`cargo clippy --manifest-path ./tools/test-examples/Cargo.toml -- -D warnings`'
uses: actions-rs/cargo@v1
with:
command: run
args: ${{ matrix.features }} --release
command: clippy
args: --manifest-path ./tools/test-examples/Cargo.toml -- -D warnings

- name: '`cargo clippy ${{ matrix.features }} --manifest-path ./tools/dep-tests/Cargo.toml -- -D warnings`'
- name: '`cargo test --all-targets --no-fail-fast`'
uses: actions-rs/cargo@v1
with:
command: clippy
args: ${{ matrix.features }} --manifest-path ./tools/dep-tests/Cargo.toml -- -D warnings
if: matrix.dep_tests
command: test
args: --all-targets --no-fail-fast

- name: '`cargo test ${{ matrix.features }} --manifest-path ./tools/dep-tests/Cargo.toml --no-fail-fast`'
- name: '`cargo run --release`'
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.features }} --manifest-path ./tools/dep-tests/Cargo.toml --no-fail-fast
if: matrix.dep_tests
command: run
args: --release

- name: '`cargo dep-tests --all-features -d 1`'
- name: '`cargo test-examples`'
uses: actions-rs/cargo@v1
with:
command: dep-tests
args: --all-features -d 1
if: matrix.dep_tests
command: test-examples
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/tools/dep-tests/Cargo.lock
/tools/test-examples/Cargo.lock
**/target/
**/*.rs.bk
578 changes: 30 additions & 548 deletions Cargo.lock

Large diffs are not rendered by default.

70 changes: 5 additions & 65 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -16,16 +16,12 @@ exclude = ["./tools"]
name = "main"
path = "src/main.rs"

[features]
jemalloc = ["jemalloc-ctl", "jemallocator"]
default = ["jemalloc"]

[dependencies]
# AtCoder 2019年言語アップデート以降に使用できるクレート

# 多バイト長整数、分数、複素数など
num = "=0.2.1"
num-bigint = "=0.2.5"
num-bigint = "=0.2.6"
num-complex = "=0.2.4"
num-integer = "=0.1.42"
num-iter = "=0.1.40"
@@ -57,36 +53,15 @@ rand_distr = "=0.2.2"
# グラフ
petgraph = "=0.5.0"

# 幾何
euclid = "=0.20.7"

# 素数
primal = "=0.2.3"
primal-check = "=0.2.3"
primal-estimate = "=0.2.1"
primal-sieve = "=0.2.9"

# 挿入順を保持するhash table
indexmap = "=1.3.0"
indexmap = "=1.3.1"

# 正規表現
regex = "=1.3.3"

# パーサーコンビネータ
nom = "=5.1.0"

# Aho–Corasick
aho-corasick = "=0.7.6"

# string similarity metrics
strsim = "=0.9.3"

# staticアイテムの遅延初期化
lazy_static = "=1.4.0"

# 浮動点小数の比較
approx = "=0.3.2"

# f64のOrd/Eq実装
ordered-float = "=1.0.2"

@@ -104,67 +79,32 @@ superslice = "=1.0.0"
itertools = "=0.8.2"
itertools-num = "=0.1.3"

# `&mut T`から`T`を『借りる』
take_mut = "=0.2.2"

# 1行で書ける`macro_rules`
defmac = "=0.2.1"

# パターンを`bool`式に
matches = "=0.1.8"

# `if`と`if let`を『まとめる』マクロ`if_chain!`
if_chain = "=1.0.0"

# `hashmap!`, `hashset!`, `btreemap!`, `btreeset!`
maplit = "=1.0.2"

# `std`のトレイトに対応するderive macro
derive_more = "=0.99.2"

# メソッド`new`を生やすderive macro
derive-new = "=0.5.8"

# 即席enum `Either<L, R>`
either = "=1.5.3"

# 標準ライブラリのVecやHashMapに対応する永続データ構造
# 永続データ構造は関数型言語によく見られるデータ構造で、要素を更新しても、そのデータ構造の
# 以前のバージョンにアクセスできる。(更新の度に差分が記録されていくイメージ)
im-rc = "=14.1.0"
im-rc = "=14.2.0"

# 可変長bit set。
fixedbitset = "=0.2.0"
bitset-fixed = "=0.1.0"

# union-find (a.k.a. disjoint-set)
union-find = "=0.3.2"

# 競技プログラミングの入出力サポート
proconio = { version = "=0.3.4", features = ["derive"] }
text_io = "=0.1.7"
proconio = { version = "=0.3.5", features = ["derive"] }
text_io = "=0.1.8"
whiteread = "=0.5.0"

# 剰余関連。普通の整数型などと同じ感覚で扱うだけで自動的にmodを取ってくれる
# 答えの整数をMで割った余りが要求される設問で便利
modtype = "=0.7.0"

# 高速なハッシュ関数
rustc-hash = "=1.0.1"

# 固定配列上のベクタ。ヒープ領域でなくスタック領域にアロケートされるので高速かもしれない
smallvec = "=1.1.0"

# 代替ヒープアロケータ。条件によってはシステムアロケータより速いことも
[target.'cfg(not(windows))'.dependencies]
jemallocator = { version = "=0.3.2", optional = true }
jemalloc-ctl = { version = "=0.3.3", optional = true }

[[test]]
name = "jemallocator"
path = "tests/test_jemallocator.rs"
required-features = ["jemalloc"]

# ---------------------------------------------------------------------

[dev-dependencies]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
**TODO** もう少し詳しく書く

- AtCoder 2019年言語アップデート後の環境向け
- Rust 1.39.0
- Rust 1.40.0
- AtCoderジャッジサーバ環境の構築用


2 changes: 1 addition & 1 deletion cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[template]
exclude = [".github", ".cargo", "dep-tests"]
exclude = [".github/workflows/ci.yml", ".cargo/config", "dep-tests.toml", "tools/**/*"]
4 changes: 1 addition & 3 deletions examples/abc057-b-text-io.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// https://atcoder.jp/contests/abc057/tasks/abc057_b

#![allow(clippy::many_single_char_names, clippy::try_err)]

use text_io::{read, try_read, try_scan};
use text_io::read;

fn main() {
let n: usize = read!();
2 changes: 1 addition & 1 deletion examples/abc073-d.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ use std::ops::Sub;

fn main() {
input! {
_n: usize,
_: usize,
m: usize,
r: usize,
rs: [NodeIndex1<u32>; r],
2 changes: 1 addition & 1 deletion examples/abc118-b-proconio.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use std::ops::{BitAnd, BitOr};
fn main() {
input! {
n: usize,
_m: usize,
_: usize,
a: [[Usize1]; n],
}

3 changes: 1 addition & 2 deletions examples/abc118-b-text-io.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// https://atcoder.jp/contests/abc118/tasks/abc118_b

use text_io::{read, try_read, try_scan};
use text_io::read;

use std::ops::{BitAnd, BitOr};

#[allow(clippy::try_err)]
fn main() {
let (n, _): (usize, usize) = (read!(), read!());
let a = (0..n)
4 changes: 2 additions & 2 deletions examples/abc121-b-text-io.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// https://atcoder.jp/contests/abc121/tasks/abc121_b

use text_io::{read, try_read, try_scan};
use text_io::read;

#[allow(clippy::many_single_char_names, clippy::try_err)]
#[allow(clippy::many_single_char_names)]
fn main() {
let (n, m, c): (usize, usize, i32) = (read!(), read!(), read!());
let b = (0..m).map(|_| read!()).collect::<Vec<i32>>();
2 changes: 1 addition & 1 deletion examples/abc129-f.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ fn main() {
l: u64,
a: u64,
b: u64,
_m: Mod,
(): Mod,
}

let count = |d| -> _ {
2 changes: 1 addition & 1 deletion examples/abc151-d.rs
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ fn main() {
.iter()
.flat_map(|&p| &neighbors[p])
.copied()
.filter(|&p| mem::replace(&mut unvisited[p], false))
.filter(|&p| mem::take(&mut unvisited[p]))
.collect();
!queue.is_empty()
})
3 changes: 1 addition & 2 deletions examples/practice-a-text-io.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// https://atcoder.jp/contests/practice/tasks/practice_1

use text_io::{read, try_read, try_scan};
use text_io::read;

#[allow(clippy::many_single_char_names, clippy::try_err)]
fn main() {
let (a, b, c, s): (u32, u32, u32, String) = (read!(), read!(), read!(), read!());

3 changes: 1 addition & 2 deletions examples/practice-b-text-io.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// https://atcoder.jp/contests/practice/tasks/practice_2

use maplit::hashset;
use text_io::{read, try_read, try_scan};
use text_io::read;

use std::{io, str};

#[allow(clippy::try_err)]
fn main() {
fn read_line() -> String {
let mut input = "".to_owned();
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.39.0
1.40.0
109 changes: 0 additions & 109 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ type UnitResult = Result<(), Box<dyn std::error::Error>>;
fn main() -> UnitResult {
run_proconio();
run_ordered_float();
run_modtype()?;
run_ascii()?;
run_bitset_fixed();
run_permutohedron();
@@ -110,114 +109,6 @@ fn test_ordered_float() {
run_ordered_float();
}

// modtype
fn run_modtype() -> UnitResult {
use modtype::cartridges::{Additive, AllowFlexibleRhs, Field, ManuallyAdjust, Multiplicative};
use modtype::{use_modtype, Cartridge, ConstValue};
use num::{BigInt, BigRational, CheckedDiv as _};

use std::marker::PhantomData;

{
#[use_modtype]
type F = modtype::F<1_000_000_007u64>;

assert_eq!((F(1_000_000_006) + F(2)).to_string(), "1");
}
{
#[allow(non_snake_case)]
modtype::thread_local::F::with(1_000_000_007u64, |F| {
assert_eq!((F(1_000_000_006) + F(2)).to_string(), "1");
});
}
{
#[allow(non_snake_case)]
let F = modtype::non_static::F::factory(1_000_000_007u64);

assert_eq!((F(1_000_000_006) + F(2)).to_string(), "1");
}
{
#[use_modtype]
type F = modtype::ModType<AllowFlexibleRhs<Field<u64>>, 1_000_000_007u64>;

let mut x = F(1);
x += F(1);
x += 1u64;
x += 1i32;
x += 1f64;
x += BigInt::from(1u32);
x += BigRational::new(BigInt::from(1u32), BigInt::from(1u32));
assert_eq!(x, F(7));
}
{
#[use_modtype]
type Z = modtype::ModType<Multiplicative<u32>, 57u32>;

assert_eq!(Z(56) * Z(56), Z(1));
assert_eq!(Z(1).checked_div(&Z(13)), Some(Z(22))); // 13・22 ≡ 1 (mod 57)
}
{
#[use_modtype]
type Z = modtype::ModType<Additive<u64>, 1_000_000_007u64>;

let mut x = Z(1_000_000_006);

x += Z(1);
assert_eq!(*x.get_mut_unchecked(), 1_000_000_007);

x += Z(u64::max_value() / 2 - 1_000_000_007);
assert_eq!(*x.get_mut_unchecked(), u64::max_value() / 2);

x += Z(1);
assert_eq!(
*x.get_mut_unchecked(),
(u64::max_value() / 2 + 1) % 1_000_000_007,
);
}
{
#[use_modtype]
type Z = modtype::ModType<ManuallyAdjust<u64>, 1_000_000_007u64>;

let mut x = Z(1_000_000_006);

x += Z(u64::max_value() - 1_000_000_006);
assert_eq!(*x.get_mut_unchecked(), u64::max_value());

x.adjust();
assert_eq!(*x.get_mut_unchecked(), u64::max_value() % 1_000_000_007);
}
{
#[rustfmt::skip] // https://github.com/rust-lang/rustfmt/issues/3673
#[derive(modtype::ModType)]
#[modtype(modulus = "M::VALUE", cartridge = "C")]
struct ModType<C: Cartridge<Target = u64>, M: ConstValue<Value = u64>> {
#[modtype(value)]
value: u64,
phantom: PhantomData<fn() -> (C, M)>,
}

impl<M: ConstValue<Value = u64>> ModType<Field<u64>, M> {
fn new(value: u64) -> Self {
Self {
value,
phantom: PhantomData,
}
}
}

#[use_modtype]
type F = ModType<Field<u64>, 1_000_000_007u64>;

assert_eq!((-F(1)).to_string(), "1000000006");
}
Ok(())
}

#[test]
fn test_modtype() -> UnitResult {
run_modtype()
}

// ascii
fn run_ascii() -> UnitResult {
use ascii::AsciiString;
9 changes: 0 additions & 9 deletions tests/defmac.rs

This file was deleted.

65 changes: 0 additions & 65 deletions tests/test_jemallocator.rs

This file was deleted.

20 changes: 0 additions & 20 deletions tools/dep-tests/Cargo.toml

This file was deleted.

484 changes: 0 additions & 484 deletions tools/dep-tests/src/main.rs

This file was deleted.