Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

菜鸟的成果。。。。3.1K。。

Posted by 201231102112 at 2013-06-10 10:12:16 on Problem 1835 and last updated at 2013-06-10 10:13:17
#include<stdio.h>
int a[6][4]={{0,1,3,4},{0,4,3,1},{1,5,4,2},{1,2,4,5},{0,5,3,2},{0,2,3,5}},
    b[6][2]={{2,5},{5,2},{3,0},{0,3},{1,4},{4,1}};
int main()
{
    char f[10];
    int m,n,i,j,p;
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d",&n);
        int x[4]={0,1,3,4},y[2]={2,5},z[3]={0,0,0},c=0,x1[4];
        while(n--)
        {
            scanf("%s",f);
            if(f[0]=='u')
            {
                for(i=0;i<4;i++)
                    if(x[i]==c)
                    {
                        y[1]=c;
                        c=y[0];
                        break;
                    }
                for(i=0;i<6;i++)
                    if(y[1]==b[i][1])
                    {
                        y[0]=b[i][0];
                        for(j=0;j<4;j++)
                            x[j]=a[i][j];
                        break;
                    }
            }
            else if(f[0]=='d')
            {
                for(i=0;i<4;i++)
                    if(x[i]==c)
                    {
                        y[0]=c;
                        c=y[1];
                        break;
                    }
                for(i=0;i<6;i++)
                    if(y[0]==b[i][0])
                    {
                        y[1]=b[i][1];
                        for(j=0;j<4;j++)
                            x[j]=a[i][j];
                        break;
                    }
            }
            else if(f[0]=='l')
            {
                while(c!=x[0])
                {
                    for(i=0;i<4;i++)
                        x1[(i+1)%4]=x[i];
                    for(i=0;i<4;i++)
                        x[i]=x1[i];
                }
                for(i=0;i<4;i++)
                    x1[(i+1)%4]=x[i];
                for(i=0;i<4;i++)
                    x[i]=x1[i];
                c=x[0];
            }
            else if(f[0]=='r')
            {
                while(c!=x[0])
                {
                    for(i=0;i<4;i++)
                        x1[(i+1)%4]=x[i];
                    for(i=0;i<4;i++)
                        x[i]=x1[i];
                }
                for(i=0;i<4;i++)
                    x1[(i+3)%4]=x[i];
                for(i=0;i<4;i++)
                    x[i]=x1[i];
                c=x[0];
            }
            else if(f[0]=='b')
            {
                while(c!=x[0])
                {
                    for(i=0;i<4;i++)
                        x1[(i+1)%4]=x[i];
                    for(i=0;i<4;i++)
                        x[i]=x1[i];
                }
                for(j=0;j<2;j++)
                {
                    for(i=0;i<4;i++)
                        x1[(i+1)%4]=x[i];
                    for(i=0;i<4;i++)
                        x[i]=x1[i];
                }
                c=x[0];
            }
            scanf("%d",&p);
            if(c==3 || c==4 || c==5)
                z[c%3]-=p;
            else
                z[c%3]+=p;
        }
        for(i=0;i<3;i++)
            printf("%d ",z[i]);
        printf("%d\n",c);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator