Advertisement
Guest User

Untitled

a guest
Sep 17th, 2013
157
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <deque>
  6. #include <stack>
  7. #include <bitset>
  8. #include <algorithm>
  9. #include <functional>
  10. #include <numeric>
  11. #include <utility>
  12. #include <sstream>
  13. #include <iostream>
  14. #include <iomanip>
  15. #include <cstdio>
  16. #include <cmath>
  17. #include <cstdlib>
  18. #include <ctime>
  19.  
  20. using namespace std;
  21.  
  22. class RouteIntersection {
  23. public:
  24.     string isValid(int, vector <int>, string);
  25. };
  26.  
  27. string RouteIntersection::isValid(int N, vector <int> coords, string moves) {
  28.     int ss = coords.size();
  29.     for(int i = 0; i < ss; i++ ){
  30.         map<int, int> values;
  31.         for(int j = i; j < ss; j++ ){
  32.             if(moves[j] == '+') values[coords[j]]++;
  33.             else values[coords[j]]--;
  34.        
  35.             bool good = true;
  36.             map<int, int>::iterator it;
  37.             for(it = values.begin(); it != values.end(); it++ ){
  38.                 if(it->second) good = false;
  39.             }
  40.             if(good) return "NOT VALID";
  41.         }
  42.     }
  43.     return "VALID";
  44. }
  45.  
  46. <%:testing-code%>
  47. //Powered by [KawigiEdit] 2.0!
Advertisement
RAW Paste Data Copied
Advertisement