SRM443 DIV2 250
サッカーリーグの勝ち点を求める問題。
std::stringとcharのキャストにとまどる。
俺アホだな。
#include <string> #include <vector> using namespace std; class SoccerLeagues{ private: int getHome(char s){ string str =""; str += s; if (str == "W"){ return 3; }else if(str == "D"){ return 1; }else { return 0; } } int getAway(char s){ string str = ""; str += s; if (str == "L"){ return 3; }else if (str == "D"){ return 1; }else { return 0; } } public: vector <int> points(vector <string> matches){ vector <int> ans; int size = matches.size(); for (int i = 0; i < (int)matches.size(); i++){ ans.push_back(0); } for (int i = 0;i < (int)matches.size(); i++){ for (int j = 0; j < (int)matches.size(); j++){ ans[i] += getHome(matches[i][j]); ans[i] += getAway(matches[j][i]); } } return ans; } };