2010-09-18から1日間の記事一覧

PKU 1035 Spell checker

PKU

Spell checker手抜きで編集距離=1としたらTLEだった。 #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; bool replace( string a, string b ); int main() { vector<string> dict; while ( true ) { string s; cin >> s; if ( s == "#" ) break; dict.</string></algorithm></vector></string></iostream>…

PKU 1034 The dog task

PKU

The dog task2部グラフの最大マッチング。 #include <iostream> #include <vector> #include <cmath> using namespace std; double dist( vector<int> a, vector<int> b ); /*int*/ vector<vector<bool> > maxmatch2( vector<vector<bool> > G ); /*int*/ vector<vector<int> > maxflow( vector<vector<int> > G, int s=0, int t=-1 ); i…</vector<int></vector<int></vector<bool></vector<bool></int></int></cmath></vector></iostream>

PKU 1036 Gangsters

PKU

Gangsters動的計画法。O(NKT)は間に合わなかった。 #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N, K, T; cin >> N >> K >> T; vector<int> t(N), P(N), S(N); for ( int i=0; i<N; i++ ) cin >> t[i]; for ( int i=0; i<N; i++ ) cin >> P[i]; for ( int i=0; i<N; i++ ) cin >> S…</n;></n;></n;></int></algorithm></vector></iostream>