Submission #3753

# Submission time Handle Problem Language Result Execution time Memory
3753 2013-08-31T08:07:16 Z BalloonCollector Hexagon travel (kriii1_H) C++
0 / 1
1500 ms 1876 KB
#include <cstdio>
#include <map>
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
map<iii,int> ma[2],mb[2],mc[2];

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

	int to=a+b+c;
	ma[0][iii(0,ii(0,0))]=0;
	mb[0][iii(0,ii(0,0))]=1;
	mc[0][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){
					if(i%2==0){
						ma[1][iii(j+1,ii(k,i-j-k))]+=ma[0][iii(j,ii(k,i-j-k))];
						mb[1][iii(j+1,ii(k,i-j-k))]+=mb[0][iii(j,ii(k,i-j-k))];
						mc[1][iii(j+1,ii(k,i-j-k))]+=mc[0][iii(j,ii(k,i-j-k))];
						ma[1][iii(j+1,ii(k,i-j-k))]%=1000000007;
						mb[1][iii(j+1,ii(k,i-j-k))]%=1000000007;
						mc[1][iii(j+1,ii(k,i-j-k))]%=1000000007;

						ma[1][iii(j,ii(k+1,i-j-k))]+=ma[0][iii(j,ii(k,i-j-k))];
						mb[1][iii(j,ii(k+1,i-j-k))]+=mb[0][iii(j,ii(k,i-j-k))];
						mc[1][iii(j,ii(k+1,i-j-k))]+=mc[0][iii(j,ii(k,i-j-k))];
						ma[1][iii(j,ii(k+1,i-j-k))]%=1000000007;
						mb[1][iii(j,ii(k+1,i-j-k))]%=1000000007;
						mc[1][iii(j,ii(k+1,i-j-k))]%=1000000007;
						if((j+k)%2==0){
							ma[1][iii(j,ii(k,i-j-k+1))]+=mb[0][iii(j,ii(k,i-j-k))];
							mb[1][iii(j,ii(k,i-j-k+1))]+=mc[0][iii(j,ii(k,i-j-k))];
							mc[1][iii(j,ii(k,i-j-k+1))]+=ma[0][iii(j,ii(k,i-j-k))];
						}else{
							ma[1][iii(j,ii(k,i-j-k+1))]+=mc[0][iii(j,ii(k,i-j-k))];
							mb[1][iii(j,ii(k,i-j-k+1))]+=ma[0][iii(j,ii(k,i-j-k))];
							mc[1][iii(j,ii(k,i-j-k+1))]+=mb[0][iii(j,ii(k,i-j-k))];
						}
						ma[1][iii(j,ii(k,i-j-k+1))]%=1000000007;
						mb[1][iii(j,ii(k,i-j-k+1))]%=1000000007;
						mc[1][iii(j,ii(k,i-j-k+1))]%=1000000007;
					}else{
						ma[0][iii(j+1,ii(k,i-j-k))]+=ma[1][iii(j,ii(k,i-j-k))];
						mb[0][iii(j+1,ii(k,i-j-k))]+=mb[1][iii(j,ii(k,i-j-k))];
						mc[0][iii(j+1,ii(k,i-j-k))]+=mc[1][iii(j,ii(k,i-j-k))];
						ma[0][iii(j+1,ii(k,i-j-k))]%=1000000007;
						mb[0][iii(j+1,ii(k,i-j-k))]%=1000000007;
						mc[0][iii(j+1,ii(k,i-j-k))]%=1000000007;

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

}
# Verdict Execution time Memory 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 36 ms 1220 KB Output is correct
6 Execution timed out 1500 ms 1876 KB Program timed out
7 Halted 0 ms 0 KB -