Submission #2203328
Source Code Expand
#include <cstdio>
#include <algorithm>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
const int mod=1e9+7;
void inc(int&a,int b){
a+=b;if(a>=mod)a-=mod;
}
void dec(int&a,int b){
a-=b;if(a<0)a+=mod;
}
int n,ans,a[100],f[100][100][51][51],g[100][100][51][51],h[51][51],h1[51][51],h2[201][102][102],h3[201][102][102];bool b[100];
int main(){
freopen("1.in","r",stdin);
scanf("%d",&n);
ref(i,1,2*n-1)scanf("%d",&a[i]);
sort(a+1,a+2*n);
ref(i,1,n-1)if(a[i+1]!=a[i])b[i]=1;b[n]=1;
ref(i,n+1,2*n-1)if(a[i-1]!=a[i])b[i]=1;
f[n][n][1][1]=1;
def(ti,n,2){
ref(j,0,2*n)ref(I,1,n-ti+2)ref(J,1,I)h3[j][I][J]=0;
def(i,2*n-1,ti){
ref(j,i-1,2*n-ti+1)
ref(I,1,n-ti+2)ref(J,1,I)
h2[j][I][J]=0;
ref(j,i,2*n-ti)if(b[i]&&b[j]){
ref(I,1,n-ti+2)ref(J,1,I)h[I][J]=0,h1[I][J]=0;
ref(t,1,n-ti+1)ref(k,1,t)if(f[i][j][t][k]){
int s=f[i][j][t][k];
inc(h[t-k+2][1],s), dec(h[t+1][k],s);
if(k+1<=t) inc(h1[k+1][k+1],s), dec(h1[t+1][k+1],s);
inc(h1[t][k],s), dec(h1[t+1][k],s);
inc(h3[j][t-k+2][1],s);
if(j<=2*n-ti) inc(h2[j+1][k+1][k+1],s), dec(h2[2*n-ti+2][k+1][k+1],s);
}
ref(I,1,n-ti+2)ref(J,1,I){
inc(h[I][J],h[I-1][J-1]); inc(h1[I][J],h1[I-1][J]);
inc(g[i][j][I][J],h[I][J]);
inc(g[i][j][I][J],h1[I][J]);
}
}
if(b[i-1])ref(j,i,2*n-ti)
ref(t,1,n-ti+2)ref(k,1,t){
inc(g[i-1][j][t][k],h3[j][t][k]);
}
ref(j,i,2*n-ti+1)
ref(I,1,n-ti+2)ref(J,1,I){
inc(h2[j][I][J],h2[j-1][I][J]);
if(b[i]&&b[j])inc(g[i][j][I][J],h2[j][I][J]);
}
}
ref(i,1,2*n-1)ref(j,1,2*n-1)if(b[i]&&b[j])
ref(t,1,n-ti+2)ref(k,1,t)
f[i][j][t][k]=g[i][j][t][k],g[i][j][t][k]=0;
}
ref(i,1,2*n-1)ref(j,i,2*n-1)ref(t,1,n)ref(k,1,t)
inc(ans,f[i][j][t][k]);
printf("%d\n",ans);
}
Submission Info
Submission Time |
|
Task |
F - Prefix Median |
User |
fangyoule |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1873 Byte |
Status |
RE |
Exec Time |
103 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:27: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("1.in","r",stdin);
^
./Main.cpp:16:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:17:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
ref(i,1,2*n-1)scanf("%d",&a[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 2000 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All |
00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 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, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt |
Case Name |
Status |
Exec Time |
Memory |
00_example_01.txt |
RE |
98 ms |
128 KB |
00_example_02.txt |
RE |
97 ms |
128 KB |
00_example_03.txt |
RE |
98 ms |
128 KB |
01.txt |
RE |
99 ms |
128 KB |
02.txt |
RE |
96 ms |
128 KB |
03.txt |
RE |
96 ms |
128 KB |
04.txt |
RE |
96 ms |
128 KB |
05.txt |
RE |
98 ms |
128 KB |
06.txt |
RE |
97 ms |
128 KB |
07.txt |
RE |
100 ms |
128 KB |
08.txt |
RE |
97 ms |
128 KB |
09.txt |
RE |
99 ms |
128 KB |
10.txt |
RE |
98 ms |
128 KB |
11.txt |
RE |
98 ms |
128 KB |
12.txt |
RE |
98 ms |
128 KB |
13.txt |
RE |
98 ms |
128 KB |
14.txt |
RE |
97 ms |
128 KB |
15.txt |
RE |
97 ms |
128 KB |
16.txt |
RE |
100 ms |
128 KB |
17.txt |
RE |
97 ms |
128 KB |
18.txt |
RE |
96 ms |
128 KB |
19.txt |
RE |
96 ms |
128 KB |
20.txt |
RE |
99 ms |
128 KB |
21.txt |
RE |
96 ms |
128 KB |
22.txt |
RE |
96 ms |
128 KB |
23.txt |
RE |
99 ms |
128 KB |
24.txt |
RE |
97 ms |
128 KB |
25.txt |
RE |
103 ms |
128 KB |
26.txt |
RE |
99 ms |
128 KB |
27.txt |
RE |
100 ms |
128 KB |
28.txt |
RE |
97 ms |
128 KB |
29.txt |
RE |
99 ms |
128 KB |
30.txt |
RE |
99 ms |
128 KB |
31.txt |
RE |
98 ms |
128 KB |
32.txt |
RE |
97 ms |
128 KB |
33.txt |
RE |
100 ms |
128 KB |
34.txt |
RE |
99 ms |
128 KB |
35.txt |
RE |
98 ms |
128 KB |
36.txt |
RE |
100 ms |
128 KB |
37.txt |
RE |
96 ms |
128 KB |
38.txt |
RE |
97 ms |
128 KB |
39.txt |
RE |
100 ms |
128 KB |
40.txt |
RE |
98 ms |
128 KB |
41.txt |
RE |
97 ms |
128 KB |
42.txt |
RE |
99 ms |
128 KB |
43.txt |
RE |
101 ms |
128 KB |
44.txt |
RE |
97 ms |
128 KB |
45.txt |
RE |
99 ms |
128 KB |
46.txt |
RE |
98 ms |
128 KB |
47.txt |
RE |
100 ms |
128 KB |
48.txt |
RE |
103 ms |
128 KB |
49.txt |
RE |
102 ms |
128 KB |
50.txt |
RE |
101 ms |
128 KB |
51.txt |
RE |
98 ms |
128 KB |