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

欣赏不敢当,就是置换群的一种应用,就是用一点儿推倒时间,不过很容易推的

Posted by nasi at 2004-10-29 16:31:42 on Problem 1955
In Reply To:能贴一下代码吗,大家都想欣赏一下哦 Posted by:achilles at 2004-10-29 10:56:46
Source

Problem Id:1955  User Id:nasi 
Memory:36K  Time:31MS
Language:C++  Result:Accepted

Source 

#include <iostream.h>
#include <string.h>

int d1[6][20]={
	{12,24,36,35,34,22,10,11,52,49,46,37,25,13,7,4,1,21,33,45},
	{15,14,27,39,38,37,25,13,46,47,48,40,28,16,9,8,7,12,24,36},
	{18,30,42,41,40,28,16,17,48,51,54,43,31,19,3,6,9,15,27,39},
	{19,20,21,33,45,44,43,31,54,53,52,34,22,10,1,2,3,18,30,42},
	{1,2,3,6,9,8,7,4,13,14,15,16,17,18,19,20,21,10,11,12},
	{46,47,48,51,54,53,52,49,45,44,43,42,41,40,39,38,37,36,35,34}
};
int d2[6][20]={
	{10,11,12,24,36,35,34,22,37,25,13,7,4,1,21,33,45,52,49,46},
	{13,25,14,15,27,39,38,37,40,28,16,9,8,7,12,24,36,46,47,48},
	{16,17,18,30,42,41,40,28,43,31,19,3,6,9,15,27,39,48,51,54},
	{43,31,19,20,21,33,45,44,34,22,10,1,2,3,18,30,42,54,53,52},
	{7,4,1,2,3,6,9,8,16,17,18,19,20,21,10,11,12,13,14,15},
	{52,49,46,47,48,51,54,53,42,41,40,39,38,37,36,35,34,45,44,43}
};

char cube[55],tmp[55];

int main()
{
	int t,c=1,i,j,p,face,turn; cin>>t;
	while(t--) {
		for(i=1;i<=54;i++) cin>>cube[i];
		cin>>p;
		for(i=0;i<p;i++) {
			cin>>face>>turn;
			memcpy(tmp,cube,55*sizeof(char));
			if(turn>0)
				for(j=0;j<20;j++) cube[d1[face][j]]=tmp[d2[face][j]];
			else
				for(j=0;j<20;j++) cube[d2[face][j]]=tmp[d1[face][j]];
		}
		cout<<"Scenario #"<<c<<":\n";
		c++;
		for(i=1;i<=9;i++) {
			if((i-1)%3==0) cout<<"     ";
			cout<<" "<<cube[i];
			if(i%3==0) cout<<endl;
		}
		for(i=10;i<=45;i++) {
			if(i!=10 && i!=22 && i!=34) cout<<" ";
			cout<<cube[i];
			if(i==21 || i==33 || i==45) cout<<"\n";
		}
		for(i=46;i<=54;i++) {
			if((i-1)%3==0) cout<<"     ";
			cout<<" "<<cube[i];
			if(i%3==0) cout<<endl;
		}
		cout<<"\n";
	}
	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