AtCoder Grand Contest 009

Submission #4023071

Source codeソースコード

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
using namespace std;
#define N 2050
#define mod 1000000007
typedef long long ll;
int n,m,K;
ll f[N<<1][N][2],s[N],ans;
void upd(ll &x,ll y) {
	x=x+y; if(x>=mod) x-=mod;
}
int main() {
	scanf("%d%d%d",&n,&m,&K);
	int t1=n%(K-1),t2=m%(K-1);
	f[0][0][0]=1;
	int i,j,lim=max(n,m)<<1;
	for(i=1;i<=lim;i++) {
		int num=i*(K-1);
		s[0]=(f[i-1][0][0]+f[i-1][0][1])%mod;
		for(j=1;j<=n;j++) {
			s[j]=(s[j-1]+f[i-1][j][0]+f[i-1][j][1])%mod;
		}
		for(j=0;j<=n;j++) {
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mod;
			if(j) f[i][j][1]=(s[j-1]-(j-K>=0?s[j-K]:0))%mod;
		}
		for(j=0;j<=n;j++) {
			if(j%(K-1)==t1 && (num-j+1)%(K-1)==t2 && num-j+1<=m) upd(ans,f[i][j][1]);
		}
	}
	printf("%lld\n",(ans+mod)%mod);
}

Submission

Task問題 E - Eternal Average
User nameユーザ名 ibuki_suika
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 831 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

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

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt,s3.txt
All 0 / 1600 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 1 ms 256 KB
02.txt WA
03.txt AC 1 ms 128 KB
04.txt AC 1 ms 128 KB
05.txt WA
06.txt AC 25 ms 127360 KB
07.txt AC 120 ms 129152 KB
08.txt WA
09.txt WA
10.txt WA
11.txt AC 112 ms 129152 KB
12.txt AC 111 ms 129280 KB
13.txt WA
14.txt AC 71 ms 98176 KB
15.txt AC 97 ms 126848 KB
16.txt AC 60 ms 89728 KB
17.txt AC 106 ms 125056 KB
18.txt AC 45 ms 125696 KB
19.txt WA
20.txt WA
21.txt AC 1 ms 256 KB
22.txt WA
23.txt WA
24.txt WA
s1.txt AC 1 ms 128 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 3 ms 8704 KB