Submission #3605

#TimeUsernameProblemLanguageResultExecution timeMemory
3605BalloonCollectorHexagon travel (kriii1_H)C++98
0 / 1
428 ms32768 KiB
#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))]); }
#Verdict Execution timeMemoryGrader output
Fetching results...