Submission #1751911


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
const int N=2010,P=1000000007;
void upd(LL &x,LL y){x=(x+y)%P;}
int n,m,p;
LL f[N][N],g[N][N],ans;
bool equ(int a,int b){
	if ((a==0)^(b==0)) return 0;
	a=(a-1)%(p-1)+1;
	b=(b-1)%(p-1)+1;
	return a==b;
}
int main(){
	scanf("%d%d%d",&n,&m,&p);
	int len=(n+m-1)/(p-1);
	f[0][0]=1;
	rep(i,1,len) rep(j,0,n){
		rep(k,0,p-1){
			if (j<k) continue;
			upd(f[i][j],f[i-1][j-k]);
		}
		rep(k,1,p-1){
			if (j<k) continue;
			upd(g[i][j],f[i-1][j-k]);
		}
		int x=j,y=i*(p-1)-j+1;
		if (equ(x,n)&&equ(y,m)&&y<=m){
			upd(ans,g[i][j]);
			printf("ans=%lld ,from g[%d][%d]=%lld\n",ans,i,j,g[i][j]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Submission Info

Submission Time
Task E - Eternal Average
User zawedx
Language C++14 (GCC 5.4.1)
Score 0
Code Size 970 Byte
Status WA
Exec Time 2104 ms
Memory 188544 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:23:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&m,&p);
                          ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1600
Status
WA × 3
WA × 25
TLE × 1
OLE × 1
Set Name Test Cases
Sample s1.txt, s2.txt, s3.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, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt WA 1 ms 2304 KB
02.txt OLE 1224 ms 188544 KB
03.txt WA 1 ms 2176 KB
04.txt WA 1 ms 2176 KB
05.txt WA 557 ms 121600 KB
06.txt WA 5 ms 23168 KB
07.txt WA 75 ms 22016 KB
08.txt WA 2 ms 2560 KB
09.txt WA 91 ms 6400 KB
10.txt WA 93 ms 5760 KB
11.txt WA 67 ms 2304 KB
12.txt WA 53 ms 2304 KB
13.txt WA 76 ms 2816 KB
14.txt WA 48 ms 2432 KB
15.txt WA 67 ms 2816 KB
16.txt WA 15 ms 2176 KB
17.txt WA 68 ms 2304 KB
18.txt WA 14 ms 4864 KB
19.txt TLE 2104 ms 139008 KB
20.txt WA 93 ms 24192 KB
21.txt WA 1 ms 2176 KB
22.txt WA 107 ms 22144 KB
23.txt WA 73 ms 3328 KB
24.txt WA 66 ms 3200 KB
s1.txt WA 1 ms 2176 KB
s2.txt WA 1 ms 2176 KB
s3.txt WA 1 ms 2304 KB