Submission #331392

#TimeUsernameProblemLanguageResultExecution timeMemory
331392evpipisFishing Game (RMI19_fishing)C++11
0 / 100
163 ms107628 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int len = 305, mod = 1e9+7; int dp[len][len][len]; vector<int> vec[len]; int add(int a, int b){ return (a+b)%mod; } int mul(int a, int b){ return (a*1LL*b)%mod; } int solve(int x, int y, int z){ if (x == 0 && y == 0 && z == 0) return 1; if (dp[x][y][z] != -1) return dp[x][y][z]; int ans = 0; for (int bit = 1; bit < 8; bit++){ int s[] = {x, y, z}; int c = 1; for (int i = 0; i < 3; i++){ if ((bit&(1<<i)) && s[i] > 0) c = mul(c, s[i]), s[i]--; else if (!(bit&(1<<i)) && s[(i+2)%3] > 0) c = mul(c, s[(i+2)%3]), s[(i+2)%3]--, s[(i+1)%3]++; else c = 0; } if (c > 0) ans = add(ans, mul(c, solve(s[0], s[1], s[2]))); } return dp[x][y][z] = ans; } int main(){ int n, t; scanf("%d %d", &n, &t); for (int x = 0; x <= 3*n; x++) for (int y = 0; y <= 3*n; y++) for (int z = 0; z <= 3*n; z++) dp[x][y][z] = -1; for (int test = 0; test < t; test++){ for (int card = 1; card <= 3*n; card++) vec[card].clear(); for (int t = 0; t < 3; t++){ for (int i = 0; i < 2*n; i++){ int card; scanf("%d", &card); vec[card].pb(t); } } int x = 0, y = 0, z = 0; for (int card = 1; card <= 3*n; card++){ int a = vec[card][0], b = vec[card][1]; if (a > b) swap(a, b); if (a == 0 && b == 1) x++; if (a == 1 && b == 2) y++; if (a == 0 && b == 2) z++; } printf("%d\n", solve(x, y, z)); } return 0; }

Compilation message (stderr)

fishing.cpp: In function 'int main()':
fishing.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |     scanf("%d %d", &n, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~
fishing.cpp:60:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   60 |                 scanf("%d", &card);
      |                 ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...