Submission #3540

#TimeUsernameProblemLanguageResultExecution timeMemory
3540BalloonCollectorHexagon travel (kriii1_H)C++98
0 / 1
60 ms7024 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,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))]; 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))]; } } } } } 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...