Submission #3753

#TimeUsernameProblemLanguageResultExecution timeMemory
3753BalloonCollectorHexagon travel (kriii1_H)C++98
0 / 1
1500 ms1876 KiB
#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 timeMemoryGrader output
Fetching results...