QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350923#7063. Space StationRong7WA 941ms239172kbC++143.2kb2024-03-11 09:58:262024-03-11 09:58:27

Judging History

你现在查看的是最新测评结果

  • [2024-03-11 09:58:27]
  • 评测
  • 测评结果:WA
  • 用时:941ms
  • 内存:239172kb
  • [2024-03-11 09:58:26]
  • 提交

answer

// Not afraid to dark.

#include <bits/stdc++.h>
using namespace std;

namespace io {
    int read_pos, read_dt; char read_char;
    inline int read (int &p = read_pos){
        p = 0, read_dt = 1; read_char = getchar ();
        while (! isdigit (read_char)){
            if (read_char == '-')
                read_dt = - 1;
            read_char = getchar ();
        }
        while (isdigit (read_char)){
            p = (p << 1) + (p << 3) + read_char - 48;
            read_char = getchar ();
        }
        return p = p * read_dt;
    }
    int write_sta[65], write_top;
    inline void write (int x){
        if (x < 0)
            putchar ('-'), x = - x;
        write_top = 0;
        do
            write_sta[write_top ++] = x % 10, x /= 10;
        while (x);
        while (write_top)
            putchar (write_sta[-- write_top] + 48);
    }
    int llen;
    inline int get_string (char c[], int &len = llen){
        len = 0;
        read_char = getchar ();
        while (read_char == ' ' || read_char == '\n' || read_char == '\r')
            read_char = getchar ();
        while (read_char != ' ' && read_char != '\n' && read_char != '\r'){
            c[++ len] = read_char;
            read_char = getchar ();
        }
        return len;
    }
}

const int N = 1e5, V = 50, mod = 1e9 + 7;
const unsigned long long sed = 23;
int n, ia, ct[V + 5], ans, jc[N + 5], inv[N + 5], inj[N + 5], sum;

inline unsigned long long Upload (vector < int > &a){
    unsigned long long res = 0;
    for (int i = V;i >= 1;-- i)
        res = res * sed + a[i];
    return res;
}

map < unsigned long long , int > mp[V + 5];
unordered_map < unsigned long long , vector < int > > ifm;

signed main (){
    io::read (n), io::read (ia);
    sum += ia;
    for (int i = 1, a;i <= n;++ i){
        ++ ct[io::read (a)];
        sum += a;
    }
    inv[1] = jc[0] = jc[1] = inj[0] = inj[1] = 1;
    for (int i = 2;i <= n;++ i){
        inv[i] = 1ll * inv[i - mod % i] * (mod / i + 1) % mod;
        inj[i] = 1ll * inj[i - 1] * inv[i] % mod;
        jc[i] = 1ll * jc[i - 1] * i % mod;
    }
    mp[ia][0ull] = 1;
    ifm[0ull] = vector < int > (51, 0);
    int sz = 1;
    for (int i = ia;i < V;++ i){
        sz += mp[i].size ();
        for (auto j : mp[i]){
            vector < int > a = ifm[j.first];
            unsigned long long xt = 1;
            for (int k = 1;k <= i;++ k, xt *= sed)
                if (ct[k] > a[k]){
                    ++ a[k];
                    unsigned long long xx = j.first + xt;
                    if (! ifm.count (xx))
                        ifm[xx] = a;
                    (mp[min (V, i + k)][xx] += 1ll * j.second * (ct[k] - a[k] + 1) % mod) %= mod;
                    -- a[k];
                }
        }
    }
    if (sum >= V)
        for (auto i : mp[V]){
            vector < int > a = ifm[i.first];
            int cnt = n - ct[0];
            for (int j = 1;j <= V;++ j)
                cnt -= a[j];
            (ans += 1ll * i.second * jc[cnt] % mod) %= mod;
        }
    else
        for (auto i : mp[sum])
            (ans += i.second) %= mod;
    io::write (1ll * ans * jc[n] % mod * inj[n - ct[0]] % mod), puts ("");
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

input:

3
2 1 2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

5
1 1 1 1 2 3

output:

54

result:

ok single line: '54'

Test #3:

score: 0
Accepted
time: 2ms
memory: 5040kb

input:

100000
47 25 43 22 17 6 15 17 45 4 14 34 46 22 0 8 2 48 41 6 49 42 21 25 48 43 2 17 27 25 38 31 39 48 13 49 24 30 36 19 29 47 48 1 4 5 12 9 21 39 30 21 8 4 9 45 18 0 3 29 26 18 24 39 31 49 22 4 46 21 27 11 11 7 8 3 26 25 29 4 1 21 34 4 44 39 13 26 33 44 5 17 10 32 37 25 44 34 17 14 40 32 27 39 41 6 ...

output:

268605493

result:

ok single line: '268605493'

Test #4:

score: 0
Accepted
time: 11ms
memory: 12052kb

input:

100000
35 39 20 34 18 5 21 21 45 38 48 44 50 42 35 23 21 18 24 9 40 18 16 20 41 27 25 4 0 5 9 7 39 26 47 13 18 27 43 45 31 20 45 39 7 29 4 41 6 39 4 27 7 24 42 10 49 21 9 21 33 12 7 2 24 13 47 11 43 25 8 18 5 14 44 9 14 50 50 19 6 18 45 41 0 27 20 44 17 19 5 26 38 19 1 30 10 32 46 4 24 27 28 32 27 3...

output:

590621358

result:

ok single line: '590621358'

Test #5:

score: -100
Wrong Answer
time: 941ms
memory: 239172kb

input:

100000
21 4 24 20 20 30 50 25 47 22 31 30 2 37 43 13 16 12 8 39 31 18 10 42 32 10 49 17 46 35 5 36 13 4 32 4 12 22 49 44 6 18 40 24 34 4 48 22 15 10 1 31 30 44 49 24 29 16 39 11 13 31 42 39 17 28 20 18 15 30 40 23 49 45 3 15 2 24 21 34 11 15 5 2 7 17 27 11 2 44 31 38 16 32 17 9 2 30 49 18 35 46 30 5...

output:

171821750

result:

wrong answer 1st lines differ - expected: '983292446', found: '171821750'