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

帮忙看看 怎么是WA

Posted by Penzias at 2007-07-10 12:18:57 on Problem 2612
#include <iostream>
using namespace std;
int isMine(int l, int mimi[]){
	for(int ww=0;ww<50;ww++){
		if(mimi[ww]==l){
			return 1;
			break;
		}
	}
	return 0;
}
int main(){
	int n;
	cin>>n;
	int mine [50];
	char c;			
	int count=0;
	int index=0;
	while(count<n*n){
		cin>>c;
		if(c=='*'){
			mine[index++]=count;				
		}
		count++;
	}
	count=0;
	int flag=0;
	char map[100];
	while(count<n*n){
		cin>>c;
		
	
			if(c=='x'){
				if(isMine(count,mine) ){
					map[count]='*';
					flag=1;
				}

				else{
					int mm[8]={count-(n-1),count-n,count-(n+1),count-1,count+1,count+n-1,count+n,count+n+1};
					if(count%n==0){
						 mm[2]=-1;
						 mm[3]=-1;
						 mm[5]=-1;
					}else if(count%n==n-1)
					{
						 mm[0]=-1;
						 mm[4]=-1;
						 mm[7]=-1;
					}
					
					int cMine=0;
					for(int i=0;i<8;i++){
						for(int j=0;j<50;j++){
							if(mm[i]==mine[j]) {
								cMine++;
								break;
							}
						}
					}
					map[count]=cMine+48;
				}
				
			}else{
				map[count]='.';
			}
		
		

		count++;

	}
	if(flag){
		for(int qqq=0;qqq<50;qqq++){
			if(mine[qqq]>=0&&mine[qqq]<n*n) map[mine[qqq]]='*';
		}
	}
	for(int u=0;u<n*n;u++){
		
		cout<<map[u];			
		
		if(u % n==n-1) cout<<endl;
	}


}

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