Submission #345952

# Submission time Handle Problem Language Result Execution time Memory
345952 2021-01-08T15:42:21 Z jacynkaa Fishing Game (RMI19_fishing) C++14
0 / 100
2000 ms 57708 KB
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10), cin.tie(0), cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define sz(X) (int)((X).size())
#ifdef LOCAL
ostream &operator<<(ostream &out, string str) {
   for (char c : str)
      out << c;
   return out;
}
template <class L, class R> ostream &operator<<(ostream &out, pair<L, R> p) { return out << "(" << p.st << ", " << p.nd << ")"; }
template <class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
   out << '{';
   for (auto it = a.begin(); it != a.end(); it = next(it))
      out << (it != a.begin() ? ", " : "") << *it;
   return out << '}';
}
void dump() { cerr << "\n"; }
template <class T, class... Ts> void dump(T a, Ts... x) {
   cerr << a << ", ";
   dump(x...);
}
#define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#define debug(...)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     \
   {}
#endif
#define int long long
const int MAXN = 205;
const int MOD = 1e9 + 7;

int tab[MAXN][MAXN][MAXN];

int change(int &AB, int &BC, int &CA, int stan) {
   if (stan == 0 && (AB + CA) != 0)
      return 0;
   if (stan == 0 && (AB + CA) == 0)
      return 1;
   if (stan == 1) {
      if (AB == 0)
         return 0;
      AB--;
      return AB + 1;
   }
   if (stan == 2) {
      if (CA == 0)
         return 0;
      CA--;
      BC++;
      return CA + 1;
   }
}

int32_t main() {
   _upgrade;
   int N, T;
   cin >> N >> T;

   tab[0][0][0] = 1;

   rep(i, 2 * N + 1) rep(j, 2 * N + 1) rep(k, 2 * N + 1) if (i + j + k != 0) for (int l = 0; l < 27; l++) {
      int mnoznik = 1;
      int AB = i;
      int BC = j;
      int CA = k;
      int ll = l;

      mnoznik *= change(AB, BC, CA, ll % 3);
      ll /= 3;

      mnoznik *= change(BC, CA, AB, ll % 3);
      ll /= 3;

      mnoznik *= change(CA, AB, BC, ll % 3);
      ll /= 3;

      if (AB + BC + CA != i + j + k && mnoznik != 0) {
         debug(i, j, k, AB, BC, CA, mnoznik, l);
         tab[i][j][k] = (tab[i][j][k] + tab[AB][BC][CA] * mnoznik) % MOD;
      }
   }
   while (T--) {
      set<int> S[3];
      int AB = 0;
      int BC = 0;
      int CA = 0;
      rep(i, 3) rep(j, 2 * N) {
         int a;
         cin >> a;
         S[i].insert(a);
      }
      rep(i, 3 * N) {
         if (S[0].count(i) && S[1].count(i))
            AB++;
         if (S[2].count(i) && S[1].count(i))
            BC++;
         if (S[2].count(i) && S[0].count(i))
            CA++;
      }
      debug(AB, BC, CA);
      cout << tab[AB][BC][CA] << endl;
   }
}

Compilation message

fishing.cpp: In function 'long long int change(long long int&, long long int&, long long int&, long long int)':
fishing.cpp:65:1: warning: control reaches end of non-void function [-Wreturn-type]
   65 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 492 KB Output isn't correct
3 Incorrect 4 ms 1132 KB Output isn't correct
4 Incorrect 23 ms 3200 KB Output isn't correct
5 Incorrect 319 ms 17132 KB Output isn't correct
6 Incorrect 543 ms 24300 KB Output isn't correct
7 Incorrect 853 ms 33004 KB Output isn't correct
8 Incorrect 1278 ms 42732 KB Output isn't correct
9 Incorrect 1780 ms 53812 KB Output isn't correct
10 Execution timed out 2092 ms 57708 KB Time limit exceeded