QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#232147 | #7063. Space Station | Ronbogo# | WA | 14ms | 4864kb | C++20 | 623b | 2023-10-29 22:26:26 | 2023-10-29 22:26:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e9+7;
int n,a[100010],cn[51];
long long ans[100010],t1,an;
void dfs(int p){
if (p>=a[n]){
int t=0;
for (int i=0;i<=50;i++)t+=cn[i];
an=(an+t1*ans[t])%N;
return ;
}
for (int i=1;i<=p;i++)
if (cn[i]){
long long tt=t1;t1=1ll*t1*cn[i]%N;cn[i]--;
dfs(p+i);
t1=tt;cn[i]++;
}
}
int main(){
cin>>n;
for (int i=0;i<=n;i++)cin>>a[i];
memset(cn,0,sizeof(cn));
sort(a+1,a+n+1);
for (int i=1;i<=n;i++)cn[a[i]]++;
ans[1]=1;
for (int i=2;i<=n;i++){
ans[i]=ans[i-1]*i%N;
}
t1=1;an=0;dfs(a[0]);cout<<an;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3696kb
input:
3 2 1 2 3
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
5 1 1 1 1 2 3
output:
54
result:
ok single line: '54'
Test #3:
score: -100
Wrong Answer
time: 14ms
memory: 4864kb
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:
492902395
result:
wrong answer 1st lines differ - expected: '268605493', found: '492902395'