답안 #273898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
273898 2020-08-19T07:48:10 Z egekabas Fishing Game (RMI19_fishing) C++14
0 / 100
358 ms 67456 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];
ll f(int a, int b, int ab){
    if(dp[a][b][ab] != -1)
        return dp[a][b][ab];
    if(a == 0 && b == 0)
        return dp[a][b][ab] = 1;
    dp[a][b][ab] = 0;
    int c = a-ab+b-ab;
    if(a == 0){
        return dp[a][b][ab] = f(b, c, b-ab);
    }
    ll ret = 0;
    if(a-ab > 0)
        ret += (a-ab)*f(b+1, c, b-ab+1)%mod;
    ret %= mod;
    if(ab > 0)
        ret += ab*f(b-1, c, b-ab)%mod;
    ret %= mod;
    //cout << a << ' ' << b << ' ' << ab << ' ' << dp[a][b][ab] << '\n';
    
    return (dp[a][b][ab]=ret);
}
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++;
    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] = -1;
    cout << f(a.size(), b.size(), abcon) << '\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;
    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)
      |                        ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 67200 KB Output isn't correct
2 Incorrect 82 ms 67192 KB Output isn't correct
3 Incorrect 79 ms 67192 KB Output isn't correct
4 Incorrect 75 ms 67192 KB Output isn't correct
5 Incorrect 147 ms 67456 KB Output isn't correct
6 Incorrect 167 ms 67256 KB Output isn't correct
7 Incorrect 199 ms 67348 KB Output isn't correct
8 Incorrect 235 ms 67324 KB Output isn't correct
9 Incorrect 294 ms 67424 KB Output isn't correct
10 Incorrect 358 ms 67320 KB Output isn't correct