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

SRM451 div2 hard

BFSやるだけなんだけど、何回かTLEした。詳細はソース内のコメントでどうぞ #include <cmath> #include <string> #include <queue> #include <vector> using namespace std; class Q { public: int y,x,c; }; class PizzaDelivery { public: int cost[50][50]; int deliverAll(vector<string> terra</string></vector></queue></string></cmath>…

SRM429 div2 hard

トポロジカルと間違えて1時間以上かかった。 ただのDFSーーでは説明になってないか とりあえず条件を全て満たすものを一つ見つける そのあと最小化するために候補全てのgcd(最大公約数)で割る #include <cstring> #include <string> #include <vector> using namespace std; typedef</vector></string></cstring>…

SRM421 div2 hard

親切に0から9まで載っていたから助かった っていうかこれないと無理 #include <string> #include <vector> using namespace std; class FloorIndicator { public: vector<int> canDig(vector<string> dig,vector<string> ind,int pos) { vector<int> r; for(int n=0;n<10;n++) { bool b=true; for(int</int></string></string></int></vector></string>…

SRM449 div2 hard

DPだと思って頑張ったのに分からないから、解説見たら全探索だった #include <algorithm> #include <cmath> #include <cstdio> #include <vector> #define OFFSET 3 using namespace std; class HexagonalBattlefieldEasy { public: int field[8][8]; int DFS(int pos) { int x=pos%7,y=pos/7,r</vector></cstdio></cmath></algorithm>…