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

PKU 2609 Ferry Loading

動的計画法 縦に車の数、横に2レーンのうち片方の車の総重量をとる DPが終わったらバックトラックして答えを求める static char dp[256][16 * 1024]; int main() { int length; cin >> length; length *= 100; vector<int> cars; dp[0][0] = -1; int bestCarIndex</int>…

PKU 2493 Rdeaalbe

並べかえられた文字列はソートして比較すると良い 短い文字列をソートしようとしてREをもらってしまった・・・ int main() { int n; cin >> n; for (int caseIndex = 1; caseIndex <= n; ++caseIndex) { map<string, int> dic; int m; cin >> m; for (int i = 0; i < m; +</string,>…

PKU 1520 Scramble Sort

標準ライブラリと関数オブジェクトの使い方の練習問題として調度良いと思う データサイズの記述がないが、適当にやっても大丈夫だと思った const string toLower(const string& s) { string result; for (string::const_iterator it = s.begin(), itEnd = s.…

PKU 1154 LETTERS

最悪ケースは下記のようなものだと思う ABCDEFGHIJKLMNOPQRST BCDEFGHIJKLMNOPQRSTU CDEFGHIJKLMNOPQRSTUV DEFGHIJKLMNOPQRSTUVW FGHIJKLMNOPQRSTUVWXY GHIJKLMNOPQRSTUVWXYZ HIJKLMNOPQRSTUVWXYZZ ... 2^26なので全探索しても通るはず static const int dx[…