2011-11-12から1日間の記事一覧

AOJ - Problem 0209 : Scene in a Picture

AOJ

問題文 ただ実装するだけの問題ですがとても面倒なので落ち着いてコードを書かないとバグが入り込むかもしれません。 #include <iostream> #include <map> using namespace std; typedef pair<int,int> P; int n,m,f[101][101],s[51][51]; bool search(int sx, int sy){ for(int y=sy</int,int></map></iostream>…

AOJ - Problem 0200 : Traveling Alone: One-way Ticket of Youth

問題文 ワーシャルフロイド法で解ける問題でした。 #include <iostream> #include <algorithm> using namespace std; const int INF = 1e+9; int main(){ int n,m; while( cin >> n >> m , n||m ){ int d[2][101][101]; for(int i=0 ; i < 101 ; i++ ){ for(int j=0 ; j < 101 ; j</algorithm></iostream>…

AOJ - Problem 0189 : Convenient Location

問題文 ワーシャルフロイド法で解くことができる問題でした。 #include <iostream> #include <algorithm> using namespace std; const int INF = 1e+9; int main(){ int n; while( cin >> n , n ){ int d[11][11], v=0, s[11]={0}; for(int i=0 ; i < 11 ; i++ ){ for(int j=0 ; j </algorithm></iostream>…

AOJ - Problem 0117 : A reward for a Carpenter

問題文 ワーシャルフロイド法で解くことができる問題でした。 ダイクストラ法でも解けるようですが、行きと帰りの最小コストだけ分かればよいのでワーシャルフロイド法を使うほうが楽なようです。(ノード数も少ない) #include <cstdio> #include <algorithm> using namespace st</algorithm></cstdio>…