金魚亭日常

読書,ガジェット,競技プログラミング

競技プログラミング

Rust で multiset

ABC253 C - Max - Min Query で、解説を見たら、 例えば c++ なら std::multiset を用いることにより高速に処理できます とか言われて、??? となったので、調べた。 multiset とは cpprefjp.github.io 日本語だと、多重集合。 問題文にも書いてあった。 R…

Rust の Struct で mutable な field

Rubyのインスタンス変数的なやつをやりたかった。 use std::cell::Cell; struct S { n: usize, cnt: Cell<i64>, } impl S { fn f(&self) { for _ in 0..self.n { self.cnt.set(self.cnt.get() + 1); } } } fn main() { let s = S { n: 10, cnt: Cell::new(0), }; </i64>…

Rust でインタラクティブ問題やるとき

TLEになるので、入力に気をつけよう。 これとか。 atcoder.jp use proconio::input; use proconio::source::line::LineSource; use std::io::{stdin, BufReader}; fn main() { let stdin = stdin(); let mut source = LineSource::new(BufReader::new(stdin.…

Rubyで優先度付きキュー

みんなのデータ構造を読んで、ヒープを実装した。 みんなのデータ構造作者:Pat MorinラムダノートAmazon 数字以外の配列とかを要素にしたいときは、そのまま突っ込んで、compare を変更する。 AtCoder でいくつか提出してみた感じでは、使えるようだった。 B…

ARC#001 B. リモコン

chokudaiさんが毎日一問問題を選んでくれる #chokudai今日の一問 4日目は 今日の一問は、ARC001より、リモコン!AtCoderはここから始まった。今の基準だと簡単目の300点くらいかな?解くことは出来るだろうけど、「5分で解いて」ってなると水色レベル。早解…

ABC#112 C. Pyramid

#chokudai今日の一問 3日目は, 今日の一門はPyramid!300点問題ながら参加者の多くを苦しめた一問。何度か言及してるので、解いてる人も多そうな問題かな。https://t.co/YQYRDqrt7t#chokudai今日の一問— chokudai(高橋 直大) (@chokudai) August 21, 2019 A…

ABC#026 C - 高橋君の給料

#chokudai今日の一問 2日目は, 今日の一問!ABC026より、高橋君の給料。今だと300点くらい?これも昨日と同じく「実装出来てほしい」系の問題。緑の人の目標タイムが20分くらい、って感じ。https://t.co/Z2MuWxj8lp— chokudai(高橋 直大) (@chokudai) Augus…

ABC113 C - ID

いつの間にかできていた #chokudai今日の一問 記念すべき1問目は,多分これ. 緑の人がこの辺の問題を解けてないのを見ると、「こいつら実装力あるって言って大丈夫か」って思っちゃう部分もある。数学的な思考力があれば、実装力が全然なくても到達できちゃ…

AtCoder ABC #137

出場はしてない A. +-x 問題文の通りに最大値を出力する. #include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <sstream> #include <string> using namespace std; void solve(int a, int b) { printf("%d\n", max({a + b, a - b, a * b})); } </string></sstream></queue></map></iostream></iomanip></cstdio></cmath></algorithm>…

Codeforces Round #580 Div2

最近は codeforces にも頑張って出ているが,こちらも出るたびにratingが下がっていく… しかし,codeforces 出ると AtCoder は使いやすいなぁと思う. Cまで開けたが,わからんかった. A. Choose Two Numbers 普通に総当たり n = int(input()) a = list(map…

AtCoder ABC #138

D まで解いた. Dはpythonで再帰したら深さがアレでREになったっぽかったのでC++に書き直すか,と思ったら時間切れだった. しかし,最近出るたびにratingが下がっていく… A. Red or Not 普通に場合分け a = int(input()) if a >= 3200: print(input()) else…

AtCoder ABC #125

A, B 1056 -> 1001 AtCoder #125 A - Biscuit Generator AtCoder ABC #125 B - Resale AtCoder ABC #125 C - GCD on Blackboard

Codeforces #551 Div2

A, B 1207 -> 1300 Codeforces #551 Div2 A - Serval and Bus Codeforces #551 Div2 B - Serval and Toy Bricks Codeforces #551 Div2 C - Serval and Parenthesis Se ...

AtCoder ABC #124

A, B, C 1074 -> 1065 AtCoder ABC #124 A - Buttons AtCoder ABC #124 B - Great Ocean View AtCoder ABC #124 C - Coloring Colorfully AtCoder ABC #124 D - Handstand

AtCoder ABC #123

A, B, C 1073-> 1074 AtCoder ABC #123 A - Five Antennas AtCoder ABC #123 B - Five Dishes AtCoder ABC #123 C - Five Transportations AtCoder ABC #123 D - Cake 123

AtCoder ABC #121

A, B, C 1071-> 1073 AtCoder ABC #121 A - White Cells AtCoder ABC #121 B - Can you solve this? AtCoder ABC #121 C - Energy Drink Collector AtCoder ABC #121 D - XOR World

AtCoder ABC #120

A, B, C 1047- > 1071 AtCoder ABC #120 A. Favorite Sound AtCoder ABC #120 B. K-th Common Divisor AtCoder ABC #120 C. Unification AtCoder ABC #120 D. Decayed Bridges

AtCoder ABC #119

A, B 1042 -> 1047 AtCoder ABC #119 A. Still TBD AtCoder ABC #119 B. Digital Gifts AtCoder ABC #119 C. Synthetic Kadomatsu

AtCoder ABC #089 D. Practical Skill Test

400点埋め Q が大きいので,前計算しておく. D が同じなので累積和を使う. AtCoder ABC #089 D. Practical Skill Test

AtCoder ABC #087 D. People on a Line

400点埋め 解説読んでもいまいちピンとこなかったので写経. AtCoder ABC #087 D. People on a Line

AtCoder AGC #028 A

x を Array にしたら RE になったので Hash で. AtCoder AGC 028 A

AtCoder ABC #085 D

400点埋め AtCoder ABC #085 D

AtCoder ABC #080 D Recording

400点埋め 最初問題を読み違えていたが,普通にループを回して間に合う. AtCoder ABC #080 D Recording

AtCoder ABC #079 D Wall

400点埋め この前書いた ダイクストラで AtCoder ABC #079 D

AtCoder ABC #071 D Coloring Dominoes

400点埋め AtCoder ABC #071 D

AtCoder ABC #110 D

AtCoder ABC #110 D

AtCoder ABC #110

C が解けなかった D は素因数分解やって組合せだろうな,というとこまでは考えたが… B のテストケースに問題があって Unrated になる可能性があるらしい. AtCoder ABC #110 C AtCoder ABC #110 B AtCoder ABC #110 A

AtCoder ABC #109

1054 -> 1011 C で詰まって終了 久しぶりに解説放送見て C D 解いたけど,やっぱりわかりやすい. A A * B が偶数なら "No" で 奇数なら "Yes" AtCoder ABC #109 A B Hash に突っ込んでやったけど,2重ループ回すのでも余裕で間に合うみたい. AtCoder ABC #…

AtCoder ABC #108

1015 -> 1054 A 偶数の個数と奇数の個数を数える. AtCoder ABC #108 A B 回転行列で. 45度回転させて √2 倍する. AtCoder ABC #108 B C a + b, b + c, c + a が kの倍数になるのは, a, b, c がkの倍数 a + b, b + c, c + a がkの倍数,つまり,a, b, c …

AtCoder ABC #090 D. Remainder Reminder

AtCoder ABC #090 D. Remainder Reminder