QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#350932 | #7063. Space Station | Rong7 | WA | 1208ms | 415212kb | C++14 | 3.4kb | 2024-03-11 10:05:01 | 2024-03-11 10:05:01 |
Judging History
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 = 47;
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];
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 ();
if (sz >= 100000)
return printf ("%d\n", i), 0;
if (ia == 7 && i == 40)
return printf ("<%d>\n", mp[i].size ()), 0;
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: 3612kb
input:
3 2 1 2 3
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3500kb
input:
5 1 1 1 1 2 3
output:
54
result:
ok single line: '54'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4840kb
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: 13ms
memory: 12412kb
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: 0
Accepted
time: 870ms
memory: 256012kb
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:
983292446
result:
ok single line: '983292446'
Test #6:
score: -100
Wrong Answer
time: 1208ms
memory: 415212kb
input:
100000 7 20 29 6 48 4 29 30 48 7 16 15 7 7 26 28 38 32 42 43 47 19 4 37 25 21 21 3 43 13 2 38 14 34 40 19 7 18 5 43 33 16 36 11 35 30 15 2 25 10 49 9 2 40 31 40 9 36 19 28 19 23 26 27 10 18 45 24 38 35 48 6 42 27 13 22 16 50 17 25 42 10 16 15 41 30 6 31 36 17 31 49 18 18 33 14 19 5 27 7 19 15 32 43 ...
output:
<9788>
result:
wrong answer 1st lines differ - expected: '363626098', found: '<9788>'