2012-07-18から1日間の記事一覧

POJ3007 Organize Your Train part II

PCKの問題のはず。 普通に文字列のままやったらTLEして腹が立ったのでローリングハッシュ書いた。 結果、rank6位に。わーい。 http://poj.org/problemstatus?problem_id=3007 #include<stdio.h> #include<vector> #include<algorithm> #include<string> #include<iostream> using namespace std; typedef pa</iostream></string></algorithm></vector></stdio.h>…

POJ1291 This Sentence is False

題名は問題名なのであしからず。2-SATに見えて考えてたらわけがわからなくなり考え直したら無向グラフだったことが判明。 思い切りunion-findが役立つ。UFかわいいよUF。 #include<stdio.h> #include<algorithm> #include<vector> #include<math.h> #include<string> #include<iostream> #include<stdlib.h> using namespace s</stdlib.h></iostream></string></math.h></vector></algorithm></stdio.h>…

POJ2004 Mix and Build

良問だと思う。文字列の長さをL,文字列数をNとすると,O(N L^2 log N). TLEぎりぎりでAC. #include<stdio.h> #include<vector> #include<algorithm> #include<string> #include<iostream> using namespace std; typedef pair<string,int>psi; typedef pair<int,psi>pisi; int len[10000]; int frm[10000]; int main() { vector<string>zvec</string></int,psi></string,int></iostream></string></algorithm></vector></stdio.h>…