QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350890#7063. Space StationRong7WA 1ms6036kbC++142.7kb2024-03-11 09:25:552024-03-11 09:25:55

Judging History

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

  • [2024-03-11 09:25:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6036kb
  • [2024-03-11 09:25:55]
  • 提交

answer

// Not afraid to dark.

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

#define int long long

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;
int n, ia, ct[V + 5], ans, jc[N + 5], inv[N + 5], inj[N + 5], sum;

map < vector < int > , int > mp[V + 5];

inline int C (int x, int y){
    return jc[x] * inj[y] % mod * inj[x - y] % mod;
}

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] = inv[i - mod % i] * (mod / i + 1) % mod;
        inj[i] = inj[i - 1] * inv[i] % mod;
        jc[i] = jc[i - 1] * i % mod;
    }
    mp[ia][vector < int > (51, 0)] = 1;
    for (int i = ia;i < V;++ i)
        for (auto j : mp[i]){
            vector < int > a = j.first;
            for (int k = 1;k <= i;++ k)
                if (ct[k] > a[k]){
                    ++ a[k];
                    (mp[min (V, i + k)][a] += j.second * (ct[k] - a[k] + 1)) %= mod;
                    -- a[k];
                }
        }
    if (sum >= V)
        for (auto i : mp[V]){
            vector < int > a = i.first;
            int cnt = n - ct[0];
            for (int i = 1;i <= V;++ i)
                cnt -= a[i];
            (ans += i.second * jc[cnt] % mod) %= mod;
        }
    else
        for (auto i : mp[sum])
            (ans += i.second) %= mod;
    io::write (ans * C (n, ct[0]) % mod), puts ("");
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3620kb

input:

3
2 1 2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5592kb

input:

5
1 1 1 1 2 3

output:

54

result:

ok single line: '54'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 6036kb

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:

584841614

result:

wrong answer 1st lines differ - expected: '268605493', found: '584841614'