2009-05-19
SRM211 Div1 Easy: grafixCorrupt
- 241.58points (5'19'' ...もっと速く!!)
- passed system test
#define sz(a) int((a).size()) #define rep(var,n) for(int var=0;var<(n);var++) class grafixCorrupt { int match(const string& s1, const string& s2){ int l=sz(s1),c=0; rep(i,l){ if(s1[i]==s2[i]) c++; } return c; } public: int selectWord(vector <string> dictionary, string candidate) { int n=sz(dictionary); int at=-1,sc=0; rep(i,n){ int s=match(dictionary[i],candidate); if (s>sc) {sc=s; at=i;} } return at; } };