Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
my ugly code#include<iostream> using namespace std; int diceNum[10001][7]; int findopposite(int i) { switch(i) { case 1:return 6; case 2:return 4; case 3:return 5; case 4:return 2; case 5:return 3; case 6:return 1; } return -1; } int findMax(int didx,int up) { int opp=findopposite(up); int maxnum=0; int i=0; while(i<=5) { i++; if(i==up||i==opp) continue; if(diceNum[didx][i]>maxnum) maxnum=diceNum[didx][i]; } return maxnum; } int main() { int t,dnum,i,j,down,up,sum,maxsum,k; cin>>t; while(t--) { cin>>dnum; maxsum=0; for(i=1;i<=dnum;i++) for(j=1;j<=6;j++) cin>>diceNum[i][j]; for(i=1;i<=6;i++) { sum=0; up=diceNum[1][i]; sum+=findMax(1,i); for(j=2;j<=dnum;j++) { for(k=1;k<=6;k++) if(diceNum[j][k]==up) break; up=diceNum[j][findopposite(k)]; sum+=findMax(j,k); } if(sum>maxsum) maxsum=sum; } cout<<maxsum<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator