2010-06-24から1日間の記事一覧

PKU 2688 Cleaning Robot

幅優先探索 及び全探索 以下のコードはPKUではTLE static const int dx[] = {0, 0, 1, -1}; static const int dy[] = {1, -1, 0, 0}; int main() { for (int w, h; cin >> w >> h && (w || h); ) { char maze[32][32]; memset(maze, 'x', sizeof(maze)); vec…

PKU 2686 Traveling by Stagecoach

拡張ダイクストラ法 [最後に訪れた頂点][使用したチケットの集合]でダイクストラ 又は[最後に訪れた頂点][何枚目のチケット化]を外側でチケットの順番を回しても良い 以下の回答はPKUではTLE struct State { double cost; int node; int nextTicket; State(d…

PKU 2685 Numeral System

やるだけ int table[0x80]; string encode(int n) { static const string letters = "ixcm"; static const string digits = "0123456789"; string s; for (int i = 0; i < 4; ++i) { int value = n % 10; n /= 10; if (value) { s = letters.substr(i, 1) + …

PKU 2684 Polygonal Line Search

幾何 図形を何らかの形で正規化して比較する ここでは始点から各点への長さと角度で正規化している typedef complex<double> P; typedef vector<pair<double, double> > Normalized; bool equals(const Normalized& first, const Normalized& second) { if (first.size() != second.size()</pair<double,></double>…

PKU 2683 Ohgas' Fortune

やるだけ int main() { int m; cin >> m; REP(caseIndex, m) { int money, year, n; cin >> money >> year >> n; int bestAnswer = 0; REP(typeIndex, n) { int type, cost; double ratio; cin >> type >> ratio >> cost; if (type) { // 複利 int m = money…