iscsi

SRM 513 D1 250 YetAnotherIncredibleMachine

Jul 28th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5. #include <vector>
  6. #include <queue>
  7. #include <set>
  8. #include <map>
  9. #include <cstdio>
  10. #include <cstdlib>
  11. #include <cctype>
  12. #include <cmath>
  13. using namespace std;
  14. typedef long long LL;
  15. #define FOR(k,a,b) for(int k(a); k < (b); ++k)
  16. #define REP(k,a) for(int k=0; k < (a); ++k)
  17.  
  18.  
  19. class YetAnotherIncredibleMachine {
  20. public:
  21.     int countWays(vector <int> platformMount, vector <int> platformLength, vector <int> balls) {
  22.         int n=platformMount.size();
  23.         int b=balls.size();
  24.         LL res=1;
  25.         LL mod=1000000009;
  26.         REP(i,n)
  27.         {
  28.             int ctr=0;
  29.             FOR(j,-1*platformLength[i],1)
  30.             {
  31.                 bool ok=true;
  32.                 REP(k,b)
  33.                 {
  34.                     if(balls[k]>=platformMount[i]+j && balls[k]<=platformMount[i]+j+platformLength[i])
  35.                     {
  36.                         ok=false;
  37.                         break;
  38.                     }
  39.                 }
  40.                 if(ok)
  41.                     ++ctr;
  42.             }
  43.             res*=ctr;
  44.             res%=mod;
  45.         }
  46.         return res;
  47.     }
  48.  
  49. };
Advertisement
Add Comment
Please, Sign In to add comment