静かで孤独な日記

のんびりたまに

ARC092-D Two Sequences

using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; int n,m,h,w; string s; ll a[200001],b[200001]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10…

ARC092-C 2D Plane 2N Points

using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; int n,m,h,w; string s; vector<pair<int,int> > aka,ao; bool past[101]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.pre</pair<int,int>…

ABC058 井井井/###

以前解いた時と解法が全く違ったので記念に。 前回は解説見て実装したからそれはそう。 そう思うと解説のような綺麗な解き方するのは中々難しい。。 #include<bits/stdc++.h> #define fi first #define se second #define show(x) cout<<#x<<"="<<x<<"\n" typedef long long ll; template<typename T> void print_to(std::ostrea</x<<"\n"></bits/stdc++.h>…

yukicoder No.513 宝探し2

最初三分探索してた。二分探索で良いのにね。 最初にxを探して、見つかったらマンハッタン距離の残りの差分がyまでの距離だから、yは探索しなくて済むね。 #include<bits/stdc++.h> using namespace std; inline int check(int minx,int maxx){ cout<<minx<<" "<<0<<"\n"; int d1;cin>>d1; if(d1==0)return -</minx<<"></bits/stdc++.h>…

yukicoder No.561 東京と京都

全部探索したいよー(と思います) 2の100乗の計算なんて無理よ… じゃあ動的計画法(dp)じゃない? よし書こう 初期の位置は東京に注意しなきゃね。 #include<bits/stdc++.h> using namespace std; int n,d; int t[101],k[101]; long long dp[101][2]; int main(){ cin>>n>>d; </bits/stdc++.h>…

yukicoder No.593 4進FizzBuzz

数が大きくなる気がするので文字列で受け取ってループ回してやっていきましょう。 毎度毎度余りを管理しておけば良いだけなのでやってる事は簡単ですね。 こんな様な考え方で桁dpとかもやりますよね。 あと、解説にある豆知識は必見ですね。(全く知りません…

yukicoder No.582 キャンディー・ボックス3

僕の大っ嫌いなゲームの必勝法考える奴です。 本当に苦手なんで誰かゲームの必勝法がわかる必勝法とか教えてください。 今回は出てきませんでしたけどnimみたいなxorとか出てくるのできる気がしないんですよね。 深く考え過ぎて解説見たらただの場合分けとか…

yukicoder No.592 括弧の対応(2)

何かと括弧ってスタックって言うデータ構造と相性が良い気がするんですよ。 なので、括弧の問題を考える時はまずゆっくりスタックの性質を考えながら解いていくと良い気がします。(僕も経験が浅いので大きい事は言えませんが) あと、類似した問題を2個程見た…

yukicoder No.609 Noelちゃんと星々

中央値に集めるのが最適なんて知らないし、考えもしなかった人は三分探索を思いついたよね。 三分探索知らない人はGoogle先生に問い合わせてみよう。(わかりやすい記事があったはず) 俺スゲー賢いとか思った僕は解説読んで知識増やしていこうね 因みに以下の…

yukicoder No.604 誕生日のお小遣い

二分探索やるんですよ。 予め、何年か指定したらいくら貰えてるか計算しやすいし。(check関数のこと) 算数が苦手な人でもこっちならいけるんじゃない?(僕のことです) あとはlong long だとオーバフローします。(unsignedつけようね)僕はミスしました。 #inc…

POJ-1742

problem 1742 -- Coins code #include <iostream> #include <algorithm> #include <functional> #include <cstdlib> #include <sstream> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <complex> #include <vector> #include <cstdio> #include <cmath> #…</cmath></cstdio></vector></complex></deque></queue></stack></map></set></string></sstream></cstdlib></functional></algorithm></iostream>

POJ-3280

problem 3280 -- Cheapest Palindrome code #include <iostream> #include <algorithm> #include <functional> #include <cstdlib> #include <sstream> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <complex> #include <vector> #include <cstdio> #inc…</cstdio></vector></complex></deque></queue></stack></map></set></string></sstream></cstdlib></functional></algorithm></iostream>

POJ-1703

problem 1703 -- Find them, Catch them code #include <iostream> #include <algorithm> #include <functional> #include <cstdlib> #include <sstream> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <complex> #include <vector> #include <cstdio> #i…</cstdio></vector></complex></deque></queue></stack></map></set></string></sstream></cstdlib></functional></algorithm></iostream>

ABC062-D 3N Numbers

D - 3N Numbers 考察 code #include<bits/stdc++.h> #define ll long long #define fi first #define se second #define show(x) cout<<#x<<"="<</bits/stdc++.h>

ARC071 D - 井井井 / ###

問題 arc071.contest.atcoder.jp エディトリアル https://atcoder.jp/img/arc071/editorial.pdf 感想 O(n+m)なのは想像がついた。 だけど、解けなかった。 xのトータルの長さとyのトータルの長さを掛けて答えが出ることも分かった。 だからあとはそのトータ…

ABC041_D 徒競走

muzukasii... pakapa104.hatenablog.com ↑wakarimiga hukai !!! http://www-erato.ist.hokudai.ac.jp/docs/autumn2013/inoue.pdf ↑naruhodo!!! 正直僕にはエディトリアルが何を言ってるのか分からなかった。 自分の頭はたしかに良くないのでググって調べてみ…