Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //misaka and elaina will carry me to red
- #pragma GCC optimize("O3,unroll-loops")
- #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
- #include <iostream>
- #include <cmath>
- #include <utility>
- #include <cassert>
- #include <algorithm>
- #include <vector>
- #include <array>
- #include <cstdio>
- #include <cstring>
- #include <functional>
- #include <numeric>
- #include <set>
- #include <queue>
- #include <map>
- #include <chrono>
- #include <random>
- #define sz(x) ((int)(x.size()))
- #define all(x) x.begin(), x.end()
- #define pb push_back
- #define eb emplace_back
- #define kill(x, s) {if(x){ cout << s << "\n"; return ; }}
- #ifndef LOCAL
- #define cerr while(0) cerr
- #endif
- using ll = long long;
- using lb = long double;
- const lb eps = 1e-9;
- const ll mod = 1e9 + 7, ll_max = 1e18;
- //const ll mod = (1 << (23)) * 119 +1, ll_max = 1e18;
- const int MX = 2e5 +10, int_max = 0x3f3f3f3f;
- struct {
- template<class T>
- operator T() {
- T x; std::cin >> x; return x;
- }
- } in;
- using namespace std;
- const int NN = (1 << 18) + 10;
- map<int, int> mm;
- vector<int> good;
- int go[80][5], ind = 2;
- ll dp[240][240][80];
- ll ans[240][240];
- int comb(int i, int j, int k){
- return i*6 + j*2 + k;
- }
- void bfs(){
- queue<int> q;
- q.push(1);
- mm[1] = 1;
- while(sz(q)){
- int b = q.front(); q.pop();
- for(int j = 0; j<=4; j++){
- int poss =0 ;
- for(int i = 0; i<18; i++){
- if(b&(1 << i)){
- int a = i/6, b = (i/2)%3, c = i%2;
- int l = j - a - b;
- if(l < 0) continue;
- if(l>=2 && c == 0){
- poss |= (1 << comb(b, l-2, 1));
- }
- l %= 3;
- poss |= (1 << comb(b, l, c));
- }
- }
- if(mm.count(poss) == 0){
- mm[poss] = ind++;
- q.push(poss);
- if(poss&(1 << comb(0, 0, 1))){
- good.pb(mm[poss]);
- }
- }
- go[mm[b]][j] = mm[poss];
- }
- }
- assert(sz(mm) <= 80);
- }
- void precomp(){
- bfs();
- dp[1][0][1] = 1;
- for(int i = 1; i<=210; i++){
- for(int j = 0; j<=210; j++){
- for(auto [v, k] : mm){
- for(int h = 0; h<=4; h++){
- (dp[i+1][j+h][go[k][h]] += dp[i][j][k]) %= mod;
- }
- }
- }
- }
- }
- void solve(){
- int n = in, m = in;
- ll ans = 0;
- for(int x : good){
- ans += dp[n+1][m][x];
- }
- ans %= mod;
- cout << ans << "\n";
- }
- signed main(){
- cin.tie(0) -> sync_with_stdio(0);
- precomp();
- int T = 1;
- cin >> T;
- for(int i = 1; i<=T; i++){
- cout << "Case #" << i << ": ";
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement