TopCoder High School SRM 24 Level one - 250 pt - Answer Evaluation editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm24
TopCoder High School SRM 24 Level one - 250 pt - Answer Evaluation solution:
#include <iostream> #include <vector> #include <sstream> using namespace std; class AnswerEvaluation { public: int getScore(vector <string> k, vector <int> s, string a) { int cnt=0, c[30]={0}; stringstream ss(a); string b; while(ss>>b) for(int i=0; i<k.size(); i++) if(b==k[i] && c[i]==0) { cnt+=s[i]; c[i]=1; break; } return cnt; } };
note: learn stringstream <sstream> in C++,
1 - http://www.dreamincode.net/forums/topic/95826-stringstream-tutorial/
2 - http://www.cplusplus.com/reference/sstream/stringstream/str/
but also peek other AC codes. i dont know stringstream of <sstream> either, but i think it keeps...
lemme dont explain my logic, cuz it is not proper i think.
No comments:
Post a Comment