Submission #2202391
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;
}
int n,ans,a[100],f[100][100][51][51],g[100][100][51][51];bool b[100];
int main(){
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){
//printf("%d\n",f[4][4][1][1]);
ref(L,1,2*n-1)ref(i,ti,2*n-L){
int j=i+L-1;
if(2*n-j<ti)continue;
ref(t,1,n-ti+1)ref(k,1,t)if(f[i][j][t][k]){
//if(i==4&&j==4&&t==1&&k==1)printf("%d\n",ti);
int s=f[i][j][t][k];
ref(K,1,k-1) inc(g[i][j][t-(k-K-1)][K],s);
ref(K,k+1,t) inc(g[i][j][t-(K-k-1)][k+1],s);
inc(g[i][j][t][k],s);
ref(I,(ti-1),i-1) if(b[I]) inc(g[I][j][t-k+2][1],s);
ref(J,j+1,2*n-ti+1) if(b[J]) inc(g[i][J][k+1][k+1],s);
}
}
ref(i,1,2*n-1)ref(j,1,2*n-1)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
2018-03-14 12:56:12+0900
Task
F - Prefix Median
User
fangyoule
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
1199 Byte
Status
TLE
Exec Time
2104 ms
Memory
202496 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:12:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:13: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
AC
2 ms
6272 KB
00_example_02.txt
AC
3 ms
14592 KB
00_example_03.txt
AC
16 ms
59776 KB
01.txt
TLE
2101 ms
202368 KB
02.txt
AC
1432 ms
187520 KB
03.txt
AC
171 ms
117504 KB
04.txt
AC
56 ms
92672 KB
05.txt
AC
27 ms
76160 KB
06.txt
AC
583 ms
154496 KB
07.txt
TLE
2104 ms
202368 KB
08.txt
AC
27 ms
76160 KB
09.txt
TLE
2104 ms
202368 KB
10.txt
AC
5 ms
22784 KB
11.txt
AC
10 ms
43264 KB
12.txt
AC
21 ms
67968 KB
13.txt
AC
396 ms
142208 KB
14.txt
AC
827 ms
166912 KB
15.txt
AC
5 ms
22784 KB
16.txt
AC
1339 ms
202368 KB
17.txt
AC
11 ms
47360 KB
18.txt
AC
2 ms
6272 KB
19.txt
AC
1 ms
2176 KB
20.txt
AC
14 ms
55680 KB
21.txt
AC
13 ms
51584 KB
22.txt
AC
4 ms
18688 KB
23.txt
AC
110 ms
113280 KB
24.txt
AC
21 ms
72064 KB
25.txt
AC
105 ms
109184 KB
26.txt
AC
170 ms
121600 KB
27.txt
AC
20 ms
67968 KB
28.txt
AC
1202 ms
195712 KB
29.txt
AC
41 ms
88576 KB
30.txt
AC
153 ms
121600 KB
31.txt
AC
4 ms
18688 KB
32.txt
AC
142 ms
117504 KB
33.txt
AC
3 ms
14592 KB
34.txt
AC
81 ms
105088 KB
35.txt
AC
879 ms
187392 KB
36.txt
AC
2 ms
6272 KB
37.txt
AC
984 ms
187520 KB
38.txt
AC
135 ms
117504 KB
39.txt
AC
45 ms
92672 KB
40.txt
AC
24 ms
76160 KB
41.txt
AC
435 ms
154496 KB
42.txt
AC
1396 ms
202368 KB
43.txt
AC
25 ms
76160 KB
44.txt
AC
1430 ms
202496 KB
45.txt
AC
5 ms
22784 KB
46.txt
AC
10 ms
43264 KB
47.txt
AC
20 ms
67968 KB
48.txt
AC
312 ms
142208 KB
49.txt
AC
621 ms
166912 KB
50.txt
AC
5 ms
22784 KB
51.txt
AC
1053 ms
202368 KB