You are viewing a single comment's thread. Return to all comments →
vector<long long> cubeSum(int n, vector<string> o) { map<tuple<int, int, int>, int> M; vector<long long> answer; for (int i=0; i < o.size(); i++) { stringstream ss(o[i]); string word; vector<int> t; while (ss >> word) { if (isdigit(word[0])) t.push_back(stoi(word)); } if (o[i][0] == 'U') M[make_tuple(t[0]-1, t[1]-1, t[2]-1)] = t[3]; else { long long temp = 0; for (auto p : M) { int x = get<0>(p.first); int y = get<1>(p.first); int z = get<2>(p.first); if (t[0]-1 <= x and x < t[3] and t[1]-1 <= y and y < t[4] and t[2]-1 <= z and z < t[5]) { temp = temp + p.second; } } answer.push_back(temp); } } return answer; }
Seems like cookies are disabled on this browser, please enable them to open this website
Cube Summation
You are viewing a single comment's thread. Return to all comments →