Submission #9537437
Source Code Expand
#include <bits/stdc++.h> #define meow(args...) fprintf(stderr, args) inline bool cmin(auto &a, const auto &b) {return b<a?(a=b, true):false;} inline bool cmax(auto &a, const auto &b) {return a<b?(a=b, true):false;} template<class Type> Type read() { Type a; bool b; unsigned char c; while(c=getchar()-48, (c>9)&(c!=253)); for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c); return b?-a:a; } auto rd=read<int>; typedef unsigned u32; typedef long long s64; typedef unsigned long long u64; const u32 P=1e9+7; u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);} u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;} u32 sum(u32 a, u32 b) {return inc(a, b);} u32 dif(u32 a, u32 b) {return dec(a, b);} u64 power(u64 a, int b) { u64 ans=1; for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P; return ans; } const int T=65555; int a[16]; u32 fac[T], ifac[T], f[T]; u64 arr(int n, int r) {return n<0||r<0||r>n?0:(u64)fac[n]*ifac[n-r]%P;} int main() { int n=rd(), m=rd(), tot=1<<n; u32 ans=0; std::generate(a, a+m, rd); fac[0]=1; for(int i=1; i<=tot; ++i) fac[i]=(u64)fac[i-1]*i%P; ifac[tot]=power(fac[tot], P-2); for(int i=tot; i--; ) ifac[i]=ifac[i+1]*(i+1llu)%P; f[0]=1; for(int i=m; i--; ) for(int j=tot; j--; ) for(int t=j; t; t&=t-1) { int k=t&-t; f[j]=(f[j]+arr(tot-a[i]-j+k, k-1)*(P-f[j-k])%P*k)%P; } for(int i=0; i<tot; ++i) ans=(ans+(u64)fac[tot-i-1]*f[i])%P; std::cout<<(u64)ans*tot%P<<std::endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Dark Horse |
User | nealchen |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1499 Byte |
Status | AC |
Exec Time | 63 ms |
Memory | 1152 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, sample-05.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, sample-05.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 6 ms | 384 KB |
02.txt | AC | 52 ms | 1024 KB |
03.txt | AC | 54 ms | 1024 KB |
04.txt | AC | 56 ms | 1024 KB |
05.txt | AC | 36 ms | 1024 KB |
06.txt | AC | 44 ms | 1024 KB |
07.txt | AC | 50 ms | 1024 KB |
08.txt | AC | 57 ms | 1024 KB |
09.txt | AC | 59 ms | 1024 KB |
10.txt | AC | 57 ms | 1024 KB |
11.txt | AC | 2 ms | 768 KB |
12.txt | AC | 6 ms | 1024 KB |
13.txt | AC | 12 ms | 1024 KB |
14.txt | AC | 18 ms | 1024 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | AC | 1 ms | 256 KB |
17.txt | AC | 1 ms | 256 KB |
18.txt | AC | 1 ms | 256 KB |
19.txt | AC | 1 ms | 256 KB |
20.txt | AC | 1 ms | 256 KB |
21.txt | AC | 61 ms | 1024 KB |
22.txt | AC | 58 ms | 1024 KB |
23.txt | AC | 55 ms | 1024 KB |
24.txt | AC | 50 ms | 1024 KB |
25.txt | AC | 39 ms | 1024 KB |
26.txt | AC | 22 ms | 1024 KB |
27.txt | AC | 2 ms | 256 KB |
28.txt | AC | 1 ms | 256 KB |
29.txt | AC | 1 ms | 256 KB |
30.txt | AC | 1 ms | 256 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 63 ms | 1152 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 1 ms | 256 KB |
35.txt | AC | 1 ms | 256 KB |
36.txt | AC | 1 ms | 256 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |
sample-03.txt | AC | 1 ms | 256 KB |
sample-04.txt | AC | 1 ms | 256 KB |
sample-05.txt | AC | 62 ms | 1024 KB |