2009-11-01から1ヶ月間の記事一覧

Volume 5 / 0525

情報オリンピック 2007予選 解答 Problem 0525 : Osenbei 公式の解説のまんま。 #include <iostream> #include <vector> using namespace std; // 数え上げ int countUp( vector< vector<int> > src ) { int i, j, cnt, result = 0; for( j=0; j</int></vector></iostream>

Volume 5 / 0538->0540

情報オリンピック 2009本選 解答 難しい……。データが大きくなるとダメダメ。 Problem 0538 : IOIOI / IOIOI BM法でやると時間切れになる。愚直にカウントして解いた。 #include <iostream> using namespace std; int main(void) { int n, m, cnt, result, i, j; char c</iostream>…

Volume 5 / 0515

情報オリンピック 2006予選 解答 Problem 0515 : School Road / 通学経路 高1で習った数学Aにあるような、碁盤目状に繋がっている点間の最短経路の数を求める問題。 深さ優先で解くと時間切れでアウト。 (x,y)までの最短経路の数 = (x-1,y)までの最短経路 + …

Volume 5 / 0510->0514

情報オリンピック 2006予選 解答 Problem 0510 : Score / 得点 足して、大きいほうを表示するだけ。 #include <iostream> using namespace std; int main(void) { int s, t, i, input; s = t = 0; for( i=0; i<4; i++ ){ cin >> input; s += input; } for( i=0; i<4; i</iostream>…

Volume 5 / 0526

情報オリンピック 2007予選 解答 Problem 0526 : Boat Travel / 船旅 最短経路問題。 新しい運行情報がある度に、そこを経由する経路を更新する。 #include <iostream> #include <vector> using namespace std; vector< vector<int> > p; void refresh( int n, int a, int b ){ int </int></vector></iostream>…

Volume 5 / 0524

情報オリンピック 2007予選 解答 Problem 0524 : Searching Constellation / 星座探し 星座のある点を基準点とおいて、基準点-その他の点間の距離を保存。(dis_m[0..m-1]) 与えられた星のおのおのの座標(pos_n[0..n-1])について、↑の距離を足したところ…

Volume 5 / 0521->0523

情報オリンピック 2007予選 解答 Problem 0521 : Change / おつり 大きい硬貨から引いていく。 #include <iostream> using namespace std; int main(void) { int n, i, cnt; int table[6] = { 500, 100, 50, 10, 5, 1 }; while( cin >> n, n!=0 ){ n = 1000 - n; cnt =</iostream>…

Volume 5 / 0536

情報オリンピック 2008予選 解答 Problem 0536 : Shuffle / シャッフル 安直に配列を使ってシミュレーションしようとすると、配列が確保できなくなってRuntime Errorが出る。カードの数10^9とかだもの。 で、情報オリンピックのサイトの解説見ても実装の仕方…

Volume 5 / 0532->0535

情報オリンピック 2008予選 解答 Problem 0532 : Time Card / タイムカード #include <iostream> using namespace std; int main(void) { int h1, h2, m1, m2, s1, s2, t; for( int i=0; i<3; i++ ){ cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2; t = (h2*60*60+m2*60+s2</iostream>…

情報オリンピック予選まであと26日

よく見たら今年が最後のチャンス。 がんばらないと。

パソコン甲子園本選行ってきました。

昨日の晩に帰ってきました。 かろうじてベスト10入り。とりあえず、入賞とか無理でした! 競技開始まで 僕のとこは本選前日の13日に会津若松入り。 岐阜から会津若松まで6時間くらいかかった。遠っ! ホテルに到着したらまず観光。飯盛山見てきた。 それで14…

パソコン甲子園本選行ってきます。

競技は明日!

Volume 1 / 0148->0152

Problem 0148 : Candy and Class Flag #include <iostream> #include <iomanip> using namespace std; int main(void) { int n; while( cin >> n ){ cout << "3C"; cout.width(2); cout.fill('0'); if( n%39 ) cout << n%39 << endl; else cout << 39 << endl; } return 0; } Pr</iomanip></iostream>…

Volume 1 / 0181

Problem 0181 : Persistence パソコン甲子園2008予選 問題09 こだわり #include <iostream> #include <vector> #include <limits.h> using namespace std; int m, n; vector<int> bw; vector< vector<int> > bsw; int calc() { int new_val; int i, j, k; for( i=1; i<=n; i++ ) bsw[1][i] = bw[i];</int></int></limits.h></vector></iostream>…

Volume 1 / 0191

パソコン甲子園2008本選 解答 Problem 0191 : Baby Tree a(1...m)回目に肥料i(0...n-1)を投入したときの最大成長率を記録していって、最終的にm回目で成長率が最大のものを出力する。 #include <iostream> #include <iomanip> #include <vector> #include <limits.h> using namespace std; str</limits.h></vector></iomanip></iostream>…

Volume 1 / 0144->0147

Problem 0144 : Packet Transportation 有向グラフの最短経路を求める問題。 ワーシャル-フロイド法で解いた。 #include <iostream> #include <vector> using namespace std; #define MAX 9999 int n; vector< vector<int> > rtr; void Floyd(){ int i, j, k, l; for( i=1; i<=n; i+</int></vector></iostream>…

Volume 1 / 0139->0143

Problem 0139 : Snakes 頭→尻尾&全身の長さ→中身の順で判定。 #include <iostream> #include <string> using namespace std; void checkA( string str ){ int length = str.size(); if( str[length-1] != '~' || length == 4 ){ cout << "NA" << endl; return; } int i, cnt =</string></iostream>…