Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <list>
- #include <map>
- #include <set>
- #include <deque>
- #include <stack>
- #include <bitset>
- #include <algorithm>
- #include <functional>
- #include <numeric>
- #include <utility>
- #include <sstream>
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- class RouteIntersection {
- public:
- string isValid(int, vector <int>, string);
- };
- string RouteIntersection::isValid(int N, vector <int> coords, string moves) {
- int ss = coords.size();
- for(int i = 0; i < ss; i++ ){
- map<int, int> values;
- for(int j = i; j < ss; j++ ){
- if(moves[j] == '+') values[coords[j]]++;
- else values[coords[j]]--;
- bool good = true;
- map<int, int>::iterator it;
- for(it = values.begin(); it != values.end(); it++ ){
- if(it->second) good = false;
- }
- if(good) return "NOT VALID";
- }
- }
- return "VALID";
- }
- <%:testing-code%>
- //Powered by [KawigiEdit] 2.0!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement