Submission #375045

#TimeUsernameProblemLanguageResultExecution timeMemory
375045iliccmarkoFishing Game (RMI19_fishing)C++14
100 / 100
371 ms215148 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define INF 1000000000 #define LINF 1000000000000000LL #define pb push_back #define all(x) x.begin(), x.end() #define len(s) (int)s.size() #define test_case { int t; cin>>t; while(t--)solve(); } #define single_case solve(); #define line cerr<<"----------"<<endl; #define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); } #define mod 1000000007LL const int N = 305; ll dp[N][N][N]; ll a[N], b[N], c[N]; ll resi(ll x, ll y, ll z) { //cout<<x<<" "<<y<<" "<<z<<endl; if(x==0&&y==0&&z==0) return 1; if(dp[x][y][z]!=-1) return dp[x][y][z]; dp[x][y][z] = 0; for(int bit = 1;bit<8;bit++) { int s[] = {x, y, z}; ll c = 1; for(int i = 0;i<3;i++) { if(bit&(1<<i)&&s[i]) s[i]--, c = (c*(s[i]+1))%mod; else if(!(bit&(1<<i))&&s[(i+2)%3]>0) c = (c*(s[(i+2)%3]))%mod, s[(i+2)%3]--, s[(i+1)%3]++; else if(!(bit&(1<<i))&&s[i]==0&&s[(i+2)%3]==0) continue; else c = 0; } dp[x][y][z] = (dp[x][y][z]+c*resi(s[0], s[1], s[2]))%mod; } return dp[x][y][z]; } int main() { ios ll n, t; cin>>n>>t; for(int i = 0;i<3*n+2;i++)for(int j = 0;j<3*n+2;j++)for(int z = 0;z<3*n+2;z++) dp[i][j][z] = -1; dp[0][0][0] = 1; while(t--) { //for(int i = 0;i<3*n+2;i++)for(int j = 0;j<3*n+2;j++)for(int z = 0;z<3*n+2;z++) dp[i][j][z] = -1; for(int i = 0;i<N;i++) a[i] = b[i] = c[i] = 0; for(int i = 0;i<2*n;i++) { ll x; cin>>x; a[x]++; } for(int i = 0;i<2*n;i++) { ll x; cin>>x; b[x]++; } for(int i = 0;i<2*n;i++) { ll x; cin>>x; c[x]++; } ll x, y, z; x = y = z = 0; for(int i = 1;i<=3*n;i++) if(a[i]&&b[i]) x++; for(int i = 1;i<=3*n;i++) if(b[i]&&c[i]) y++; for(int i = 1;i<=3*n;i++) if(a[i]&&c[i]) z++; cout<<resi(x, y, z)<<endl; } return 0; }

Compilation message (stderr)

fishing.cpp: In function 'long long int resi(long long int, long long int, long long int)':
fishing.cpp:27:20: warning: narrowing conversion of 'x' from 'long long int' to 'int' [-Wnarrowing]
   27 |         int s[] = {x, y, z};
      |                    ^
fishing.cpp:27:23: warning: narrowing conversion of 'y' from 'long long int' to 'int' [-Wnarrowing]
   27 |         int s[] = {x, y, z};
      |                       ^
fishing.cpp:27:26: warning: narrowing conversion of 'z' from 'long long int' to 'int' [-Wnarrowing]
   27 |         int s[] = {x, y, z};
      |                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...