Submission #274090

# Submission time Handle Problem Language Result Execution time Memory
274090 2020-08-19T08:27:09 Z egekabas Fishing Game (RMI19_fishing) C++14
0 / 100
1374 ms 404044 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
ll mod = 1e9+7;
int n, t;
ll dp[209][209][209][3];
ll fact[209];
ll f(int a, int b, int ab, int cur){
    if(a < 0 || b < 0 || ab < 0)return 0;
    if(dp[a][b][ab][cur] != -1)
        return dp[a][b][ab][cur];
    if(a == 0)
        return dp[a][b][ab][cur] = fact[b];
    dp[a][b][ab][cur] = 0;
    int c = a-ab+b-ab;
    dp[a][b][ab][cur] += ab*f(b-1, c, b-ab, (cur+1)%3)%mod;
    dp[a][b][ab][cur] += (a-ab)*(b-ab+1)*f(c-1, a-1, a-ab-1, (cur+2)%3)%mod;
    dp[a][b][ab][cur] += (a-ab)*ab*(a-ab+1)*f(a-1, b, ab-1, cur)%mod;
    if(cur != 0){
        dp[a][b][ab][cur] += (a-ab)*ab*(c-(a-ab))*ab*f(b-1, c, b-ab, (cur+1)%3)%mod;
    }
    if(cur == 1){
        dp[a][b][ab][cur] += (a-ab)*ab*(c-(a-ab))*(a-ab)*(b-ab+1)*f(c-1, a-1, a-ab-1, (cur+2)%3)%mod;    
    }
    dp[a][b][ab][cur] %= mod;
    return dp[a][b][ab][cur];    
}
vector<int> clean(vector<int> v){
    sort(all(v));
    vector<int> ret;
    for(int i = 0; i < v.size(); ++i){
        if(i == v.size()-1 || v[i] != v[i+1])
            ret.pb(v[i]);
        else
            ++i;
    }
    return ret;
}
void solve(){
    vector<int> a(2*n), b(2*n), c(2*n);
    for(int i = 0; i < 2*n; ++i)
        cin >> a[i];
    for(int i = 0; i < 2*n; ++i)
        cin >> b[i];
    for(int i = 0; i < 2*n; ++i)
        cin >> c[i];
    a = clean(a);
    b = clean(b);
    int abcon = 0;
    for(int i = 0; i < a.size(); ++i)
        for(int j = 0; j < b.size(); ++j)
            if(a[i] == b[j])
                abcon++;
    cout << f(a.size(), b.size(), abcon, 0) << '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> t;
    for(int i = 0; i <= 200; ++i)
        for(int j = 0; j <= 200; ++j)
            for(int k = 0; k <= 200; ++k)
                dp[i][j][k][0] = dp[i][j][k][1] = dp[i][j][k][2] = -1;
    fact[0] = 1;
    for(ll i = 1; i <= 200; ++i)
        fact[i] = i*fact[i-1]%mod;
    while(t--){
        solve();
    }    
}

Compilation message

fishing.cpp: In function 'std::vector<int> clean(std::vector<int>)':
fishing.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 0; i < v.size(); ++i){
      |                    ~~^~~~~~~~~~
fishing.cpp:43:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if(i == v.size()-1 || v[i] != v[i+1])
      |            ~~^~~~~~~~~~~~~
fishing.cpp: In function 'void solve()':
fishing.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i = 0; i < a.size(); ++i)
      |                    ~~^~~~~~~~~~
fishing.cpp:62:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int j = 0; j < b.size(); ++j)
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 199416 KB Output isn't correct
2 Incorrect 128 ms 199448 KB Output isn't correct
3 Incorrect 131 ms 199416 KB Output isn't correct
4 Incorrect 139 ms 199416 KB Output isn't correct
5 Incorrect 334 ms 199416 KB Output isn't correct
6 Incorrect 550 ms 199672 KB Output isn't correct
7 Runtime error 1374 ms 403912 KB Execution killed with signal 11
8 Runtime error 1150 ms 403832 KB Execution killed with signal 11
9 Runtime error 1020 ms 403940 KB Execution killed with signal 11
10 Runtime error 986 ms 404044 KB Execution killed with signal 11