Advertisement
YEZAELP

o59_oct_c1_staying

Dec 20th, 2021
678
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. const int N = 1e3 + 10;
  5. const int K = 1e3 + 10;
  6. const int Mod = 1e9 + 7;
  7. int dp[3][N][K][8];
  8. bool vs[3][N][K][8];
  9. vector <int> g[3];
  10. int n, k[3]; /// 7
  11.  
  12. int f(int u, int day, int cur, int abc){
  13.     if(day == n) return abc == 7;
  14.     if(vs[u][day][cur][abc]) return dp[u][day][cur][abc];
  15.     vs[u][day][cur][abc] = true;
  16.     if(cur + 1 <= k[u])
  17.         dp[u][day][cur][abc] = f(u, day + 1, cur + 1, abc) % Mod;
  18.     for(auto v: g[u])
  19.         dp[u][day][cur][abc] = ( dp[u][day][cur][abc] + f(v, day + 1, 1, abc | (1 << v)) ) % Mod;
  20.     return dp[u][day][cur][abc];
  21. }
  22.  
  23. int main(){
  24.  
  25.     scanf("%d", &n);
  26.  
  27.     scanf("%d %d %d", &k[0], &k[1], &k[2]);
  28.  
  29.     g[0].push_back(1);
  30.     g[0].push_back(2);
  31.     g[1].push_back(2);
  32.     g[2].push_back(0);
  33.  
  34.     cout << f(0, 1, 1, 1);
  35.  
  36.     return 0;
  37. }
Advertisement
RAW Paste Data Copied
Advertisement