2013-09-01から1ヶ月間の記事一覧
最近CFがやたらと好調。A: 二分探索した。どうとでもなるらしい。 #include<stdio.h> #include<algorithm> using namespace std; int b[100100]; int main(){ int a; scanf("%d",&a); for(int i=0;i</algorithm></stdio.h>
やらかしました。手元とPKUでは正解なのにAOJではWAだったのはどうやら配列外参照のせいらしい。 C++は配列外処理のレスポンスが環境によってかわりすぎる。JavaみたいにすべてREにしてほしい。 (CFでC++の配列外処理はhackすることができない)やってること…
とりあえず自分が書いたソースコードを張ります。Day2 Practice (KMFContest)F: segtree的な #include<bits/stdc++.h> using namespace std; int b[100000]; int segtree[2200000]; int INF=999999999; void add(int a,int b){ a+=(1<<20); while(a){ segtree[a]=min(segtre</bits/stdc++.h>…
数え上げ問題集数え上げの問題をある程度まとめます。といっても多すぎて面倒なので、まとまって存在するものはリンクを張ります。 また、検索の都合上「答えを1000000007で割った余りを求める」以外の形式の数え上げは見落とされがちなので、そこらへんは割…
不思議。A:GCD求めてほげるだけ。落ちた。 #include<stdio.h> #include<algorithm> using namespace std; int b[100]; int gcd(int a,int b){ while(b){ a%=b; int c=a; a=b; b=c; }return a; } int main(){ int a; scanf("%d",&a); for(int i=0;i</algorithm></stdio.h>
5位でした!A: ビットDPするだけなので飛ばす。あとから戻ってきて面倒だが書く。 #include<stdio.h> #include<algorithm> using namespace std; int dp[15][15][1<<16]; int mod=1000000007; int main(){ int a,b; scanf("%d%d",&a,&b); for(int i=0;i<(1<</algorithm></stdio.h>
今日は実装が楽系多め。9D - How many trees? dp[i][j]:=i個のノードを持つ高さj以上の二分木の個数 #include<stdio.h> #include<algorithm> using namespace std; long long dp[100][100]; long long calc(int a,int b){ if(~dp[a][b])return dp[a][b]; if(a</algorithm></stdio.h>
解法を考えて整理してからPCを起動するとはかどる。213B - Numbers 桁ごとに挿入するタイプの数え上げDP。leading 0を取り除くために最上位をループで決めています。 #include<stdio.h> #include<algorithm> using namespace std; int d[10]; long long dp[10][101]; int C[1000]</algorithm></stdio.h>…
だんだん難しい問題に当たるようになってきて大変。156C - Cipher よく考えたら文字関係無いじゃん… #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; int dp[101][2600]; char str[128]; int main(){ int a; int mod=1000000007; dp[0][0]=1; for(int i=0;i</string.h></algorithm></stdio.h>…
これ、⑳までいったらどうしようと思ったんですが、Unicodeには㊿まであるっぽいので、ひとまず安泰です。128C - Games with Rectangle (a-1)C(c*2)+(b-1)C(c*2)。成立しないケースが邪魔。配列外で死。 #include<stdio.h> #include<algorithm> using namespace std; long long C[</algorithm></stdio.h>…
今日はCodeforcesの問題を解くのをお休みにして、Readforcesの問題を解くことにしました。229C - Triangles 問題文を読み間違えていた。正しく読めば簡単。 Knの三角形はnC3個。 ここからm辺取り除くとまずm*(n-2)個の三角形が消え、包除原理で頂点を共有す…
今日は軽めです。107B - Basketball Team 確率の計算を普通にやる。 #include<stdio.h> #include<algorithm> using namespace std; int d[1000]; int main(){ int a,b,c; scanf("%d%d%d",&a,&b,&c); for(int i=0;i</algorithm></stdio.h>
今日もcombinatorics埋めていきます。319A - Malek Dance Club 難しそうだが考えたら独立だった。 #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; char str[128]; int main(){ scanf("%s",str); int mod=1000000007; int n=strlen(str); int ret=0; for(i</string.h></algorithm></stdio.h>…
敗北しました。250:きつね やるだけ。 public class FoxAndChess{ public String ableToMove(String a,String b){ int s[]=new int[100]; int S[]=new int[100]; int t[]=new int[100]; int T[]=new int[100]; int m=0; int n=0; for(int i=0;i
つづきです。Solvedがだんだん減っていきます。84B - Magical Array 数えるだけ。オーバーフローした。 #include<stdio.h> int a[100000]; int main(){ int b; scanf("%d",&b); for(int i=0;i</stdio.h>
今日は簡単な順にcombinatoricsを埋めています。Solvedの多い問題からCombinatoricsを埋めていきます。131C - The World is a Theatre コンビネーションの掛け算やるだけ。 #include<stdio.h> long long C[61][61]; int main(){ int a,b,c; scanf("%d%d%d",&a,&b,&c);</stdio.h>…
せっかくの機会なので、CFの過去問をガチで埋めていこうと思います。しばらく経つ頃にはきっと私はレッドコーダーになっていることでしょう。(現在Div1底辺)昨日といた問題103D こういう手の問題で平方分割をするのは典型ですが、この問題はクエリ先読みが大…
writerやってました。講評を書くことにします。Day 1 川越市街 初日にレアンと会う約束をしていたものの、道に迷ってしまい気がついたら家の方向への道をあるいていた、というのが元ネタの出題です。 川越駅と本川越駅と川越市駅は密集しています。三つとも…