답안 #3605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3605 2013-08-31T06:53:00 Z BalloonCollector Hexagon travel (kriii1_H) C++
0 / 1
428 ms 32768 KB
#include <cstdio>
#include <map>
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
map<iii,int> ma,mb,mc;

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);

	int to=a+b+c;
	ma[iii(0,ii(0,0))]=0;
	mb[iii(0,ii(0,0))]=1;
	mc[iii(0,ii(0,0))]=0;

	for(int i=0;i<to;i++){
		for(int j=0;j<=i && j<=a;j++){
			for(int k=0;j+k<=i && k<=b;k++){
				if(i-j-k<=c){
					ma[iii(j+1,ii(k,i-j-k))]+=ma[iii(j,ii(k,i-j-k))];
					mb[iii(j+1,ii(k,i-j-k))]+=mb[iii(j,ii(k,i-j-k))];
					mc[iii(j+1,ii(k,i-j-k))]+=mc[iii(j,ii(k,i-j-k))];
					ma[iii(j+1,ii(k,i-j-k))]%=1000000007;
					mb[iii(j+1,ii(k,i-j-k))]%=1000000007;
					mc[iii(j+1,ii(k,i-j-k))]%=1000000007;

					ma[iii(j,ii(k+1,i-j-k))]+=ma[iii(j,ii(k,i-j-k))];
					mb[iii(j,ii(k+1,i-j-k))]+=mb[iii(j,ii(k,i-j-k))];
					mc[iii(j,ii(k+1,i-j-k))]+=mc[iii(j,ii(k,i-j-k))];
					ma[iii(j,ii(k+1,i-j-k))]%=1000000007;
					mb[iii(j,ii(k+1,i-j-k))]%=1000000007;
					mc[iii(j,ii(k+1,i-j-k))]%=1000000007;
					if((j+k)%2==0){
						ma[iii(j,ii(k,i-j-k+1))]+=mb[iii(j,ii(k,i-j-k))];
						mb[iii(j,ii(k,i-j-k+1))]+=mc[iii(j,ii(k,i-j-k))];
						mc[iii(j,ii(k,i-j-k+1))]+=ma[iii(j,ii(k,i-j-k))];
					}else{
						ma[iii(j,ii(k,i-j-k+1))]+=mc[iii(j,ii(k,i-j-k))];
						mb[iii(j,ii(k,i-j-k+1))]+=ma[iii(j,ii(k,i-j-k))];
						mc[iii(j,ii(k,i-j-k+1))]+=mb[iii(j,ii(k,i-j-k))];
					}
					ma[iii(j,ii(k,i-j-k+1))]%=1000000007;
					mb[iii(j,ii(k,i-j-k+1))]%=1000000007;
					mc[iii(j,ii(k,i-j-k+1))]%=1000000007;
				}
			}
		}
	}
	printf("%d\n%d\n%d\n",ma[iii(a,ii(b,c))],mc[iii(a,ii(b,c))],mb[iii(a,ii(b,c))]);

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1220 KB Output is correct
2 Correct 0 ms 1220 KB Output is correct
3 Correct 0 ms 1220 KB Output is correct
4 Correct 0 ms 1220 KB Output is correct
5 Correct 92 ms 7028 KB Output is correct
6 Memory limit exceeded 428 ms 32768 KB Memory limit exceeded
7 Halted 0 ms 0 KB -