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

55555,实在不知道哪里错了,哪位过了的GGJJ都生成点数据……

Posted by FinalLaugh at 2004-10-09 14:38:34 on Problem 1835
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws IOException {
        System.setIn(new FileInputStream("in.txt"));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        int[][][][]val=new int[6][6][4][2];
        //1:head,2:forward
        //0:x,1:y,2:z,3:-x,4:-y,5:-z
        //0:left,1:right,2:up,3:down
        //0:head,1:forward
        for (int i=0;i<6;i++){
            for (int j=0;j<6;j++){
                if (i==j)continue;
                int left,right;
                left=(j+5)%6;
                while(left==i||left==(i+3)%6){
                    left+=5;
                    left%=6;
                }
                right=(j+1)%6;
                while(right==i||right==(i+3)%6){
                    right++;
                    right%=6;
                }
                val[i][j][0][0]=i;
                val[i][j][1][0]=i;
                if (i<3){
                    val[i][j][0][1]=left;
                    val[i][j][1][1]=right;
                }
                else{
                    val[i][j][1][1]=left;
                    val[i][j][0][1]=right;
                }
                val[i][j][2][0]=(j+3)%6;
                val[i][j][2][1]=i;
                val[i][j][3][0]=j;
                val[i][j][3][1]=(i+3)%6;
            }
        }
        //System.out.println(val[2][0][1][0]+" "+val[2][0][1][1]);
        int cn=Integer.parseInt(in.readLine());
        for (int i=0;i<cn;i++){
            int n=Integer.parseInt(in.readLine());
            int[]pos=new int[6];
            int h=2,f=0,nh,nf;
            for (int j=0;j<n;j++){
                String str=in.readLine();
                StringTokenizer st=new StringTokenizer(str);
                String action=st.nextToken().toLowerCase().intern();
                int num=Integer.parseInt(st.nextToken());
                if (action=="left"){
                    nh=val[h][f][0][0];
                    nf=val[h][f][0][1];
                }
                else if(action=="right"){
                    nh=val[h][f][1][0];
                    nf=val[h][f][1][1];
                }
                else if(action=="up"){
                    nh=val[h][f][2][0];
                    nf=val[h][f][2][1];
                }
                else if(action=="down"){
                    nh=val[h][f][3][0];
                    nf=val[h][f][3][1];
                }
                else if(action=="forward"){
                    nh=h;
                    nf=f;
                }
                else if (action=="back"){
                    nh=h;
                    nf=(f+3)%6;
                }
                else{
                    nh=-1;
                    nf=-1;
                }
                if (nf!=-1){
                    h=nh;
                    f=nf;
                    pos[f]+=num;
                    //for (int k=0;k<6;k++){
                        //System.out.print(pos[k]+" ");
                    //}
                    //System.out.println();
                }
            }
            System.out.println((pos[0]-pos[3])+" "+(pos[1]-pos[4])+" "+(pos[2]-pos[5])+" "+f);
        }
        
        
        in.close();
    }
}

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