Submission #3054235


Source Code Expand

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <deque>

const int MOD = 1000000007;
using ll = long long;
using namespace std;
vector<vector<ll>> part(201, vector<ll>(1001, 0));
using P = pair<int, int>;

ll perms(vector<int> &k1, int k){
    deque<P> d;
    d.emplace_back(k1[0], 1);
    for (int i = 1; i < k1.size(); ++i) {
        if(d.back().first == k1[i]) d.back().second++;
        else d.emplace_back(k1[i], 1);
    }
    vector<vector<ll>> dp(d.size() + 1, vector<ll>(k + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < d.size(); ++i) {
        for (int j = 0; j < k + 1; ++j) {
            for (int l = 0; l < k - j + 1; ++l) {
                dp[i+1][j + l] = (dp[i+1][j+l] + ((ll)dp[i][j] * part[d[i].second][l]) % MOD ) % MOD;
            }
        }
    }
    return dp[d.size()][k];
}

int main() {
    unsigned int n, m;
    cin >> n >> m;
    part[0][0] = 1;
    for (int i = 1; i <= 200; ++i) {
        int now = i, prv = now-1;
        part[now].assign(1001, 0);
        for (int j = 0; j <= 1000; ++j) {
            if(j >= i) part[now][j] = (part[prv][j] + part[now][j-i]) % MOD;
            else part[now][j] = part[prv][j];
        }
    }
    vector<int> Ka(n), Kb(m);
    for (int i = 0; i < n; ++i) {
        cin >> Ka[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> Kb[i];
    }
    int ka = accumulate(Ka.begin(), Ka.end(), 0), kb = accumulate(Kb.begin(), Kb.end(), 0);
    cout << (perms(Ka, kb) * perms(Kb, ka) ) % MOD << "\n";
    return 0;
}

Submission Info

Submission Time
Task C - Kill/Death
User firiexp
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1582 Byte
Status AC
Exec Time 145 ms
Memory 2092 KB

Judge Result

Set Name All
Score / Max Score 500 / 500
Status
AC × 71
Set Name Test Cases
All 01_sample00, 01_sample01, 01_sample02, 01_sample03, 01_sample04, 02_minimal00, 02_minimal01, 02_minimal02, 02_minimal03, 03_maximal00, 03_maximal01, 04_random-easy00, 04_random-easy01, 04_random-easy02, 04_random-easy03, 04_random-easy04, 04_random-easy05, 04_random-easy06, 04_random-easy07, 04_random-easy08, 04_random-easy09, 04_random-easy10, 04_random-easy11, 04_random-easy12, 04_random-easy13, 04_random-easy14, 04_random-easy15, 04_random-easy16, 04_random-easy17, 04_random-easy18, 04_random-easy19, 05_random-large00, 05_random-large01, 05_random-large02, 05_random-large03, 05_random-large04, 05_random-large05, 05_random-large06, 05_random-large07, 05_random-large08, 05_random-large09, 05_random-large10, 05_random-large11, 05_random-large12, 05_random-large13, 05_random-large14, 05_random-large15, 05_random-large16, 05_random-large17, 05_random-large18, 05_random-large19, 06_random00, 06_random01, 06_random02, 06_random03, 06_random04, 06_random05, 06_random06, 06_random07, 06_random08, 06_random09, 06_random10, 06_random11, 06_random12, 06_random13, 06_random14, 06_random15, 06_random16, 06_random17, 06_random18, 06_random19
Case Name Status Exec Time Memory
01_sample00 AC 2 ms 1792 KB
01_sample01 AC 2 ms 1792 KB
01_sample02 AC 2 ms 1792 KB
01_sample03 AC 2 ms 1792 KB
01_sample04 AC 3 ms 1792 KB
02_minimal00 AC 2 ms 1792 KB
02_minimal01 AC 5 ms 1792 KB
02_minimal02 AC 5 ms 1792 KB
02_minimal03 AC 7 ms 1792 KB
03_maximal00 AC 12 ms 1920 KB
03_maximal01 AC 7 ms 1792 KB
04_random-easy00 AC 2 ms 1792 KB
04_random-easy01 AC 2 ms 1792 KB
04_random-easy02 AC 2 ms 1792 KB
04_random-easy03 AC 2 ms 1792 KB
04_random-easy04 AC 2 ms 1792 KB
04_random-easy05 AC 2 ms 1792 KB
04_random-easy06 AC 2 ms 1792 KB
04_random-easy07 AC 2 ms 1792 KB
04_random-easy08 AC 2 ms 1792 KB
04_random-easy09 AC 2 ms 1792 KB
04_random-easy10 AC 2 ms 1792 KB
04_random-easy11 AC 2 ms 1792 KB
04_random-easy12 AC 2 ms 1792 KB
04_random-easy13 AC 2 ms 1792 KB
04_random-easy14 AC 2 ms 1792 KB
04_random-easy15 AC 2 ms 1792 KB
04_random-easy16 AC 2 ms 1792 KB
04_random-easy17 AC 2 ms 1792 KB
04_random-easy18 AC 2 ms 1792 KB
04_random-easy19 AC 2 ms 1792 KB
05_random-large00 AC 121 ms 2076 KB
05_random-large01 AC 145 ms 2048 KB
05_random-large02 AC 132 ms 2064 KB
05_random-large03 AC 122 ms 2076 KB
05_random-large04 AC 125 ms 2064 KB
05_random-large05 AC 133 ms 2064 KB
05_random-large06 AC 132 ms 2060 KB
05_random-large07 AC 130 ms 2072 KB
05_random-large08 AC 125 ms 2080 KB
05_random-large09 AC 121 ms 2080 KB
05_random-large10 AC 125 ms 2076 KB
05_random-large11 AC 126 ms 2080 KB
05_random-large12 AC 130 ms 2088 KB
05_random-large13 AC 134 ms 2068 KB
05_random-large14 AC 131 ms 2060 KB
05_random-large15 AC 112 ms 2092 KB
05_random-large16 AC 129 ms 2080 KB
05_random-large17 AC 135 ms 2056 KB
05_random-large18 AC 131 ms 2080 KB
05_random-large19 AC 122 ms 2080 KB
06_random00 AC 60 ms 2020 KB
06_random01 AC 3 ms 1792 KB
06_random02 AC 5 ms 1792 KB
06_random03 AC 75 ms 2032 KB
06_random04 AC 27 ms 1920 KB
06_random05 AC 34 ms 1920 KB
06_random06 AC 13 ms 1920 KB
06_random07 AC 24 ms 1920 KB
06_random08 AC 13 ms 1920 KB
06_random09 AC 70 ms 2048 KB
06_random10 AC 6 ms 1792 KB
06_random11 AC 22 ms 1920 KB
06_random12 AC 72 ms 2048 KB
06_random13 AC 19 ms 1920 KB
06_random14 AC 23 ms 1920 KB
06_random15 AC 2 ms 1792 KB
06_random16 AC 40 ms 1920 KB
06_random17 AC 26 ms 1920 KB
06_random18 AC 13 ms 1920 KB
06_random19 AC 16 ms 1920 KB