예제 #1
0
int main()
{
   int n,m,k,i,j,flag=0,blast=0;
   scanf("%d%d%d",&n,&m,&k);
   for(i=0;i<n&&flag==0;i++)
   {
       for(j=0;j<n&&flag==0;j++)
       {
           char c=Survey(i,j);
           if(c=='M')
            {
                Neutralize(i,j);
                blast++;
            }
           if(blast==m)
               flag++;
            if(c=='0')
                j++;
       }
   }

   printf("Done");
return 0;
}
예제 #2
0
static void Neutralize_Hook()
{
    REG_EAX(int, player);
    Neutralize(player & 0xff);
}
예제 #3
0
int main(){
  int mines_sofar = 0;
  int N,M,K,i,j,p,q,p1,q1,m,n;
  int board[50][50];
  char res;
  scanf("%d %d %d",&N,&M,&K);
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      board[i][j] = -2;
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(board[i][j] == -2){
	board[i][j] = -1;
	res = Survey(i,j);
	//	printf("%d\n",res == '0');
	if( res == 'M'){
	  Neutralize(i,j);
	  mines_sofar++;
	}else if(res == '0'){
	  if(i-1 >= 0){
	    p = i-1;
	  }
	  else{
	    p = i;
	  }
	  if(j-1 >= 0){
	    q = j-1;
	  }
	  else{
	    q = j;
	  }
 
	  if(i+1 < N){
	    p1 = i+1;
	  }
	  else{
	    p1 = i;
	  }
	  if(j+1 < N){
	    q1 = j+1;
	  }
	  else{
	    q1 = j;
	  }
	  for(m=p;m<=p1;m++){
	    for(n=q;n<=q1;n++){
	      board[m][n] = -1;
	    }
	  }	
	}
	else if(res == '8'){
	  Neutralize(i,j+1);
	  board[i][j+1] = -1;
	  mines_sofar++;

	  Neutralize(i+1,j-1);
	  board[i+1][j-1] = -1;
	  mines_sofar++;

	  Neutralize(i+1,j);
	  board[i+1][j] = -1;
	  mines_sofar++;

	  Neutralize(i+1,j+1);
	  board[i+1][j+1] = -1;
	  mines_sofar++;
	}
	else{
	  if(i-1 >= 0){
	    p = i-1;
	  }
	  else{
	    p = i;
	  }
	  if(j-1 >= 0){
	    q = j-1;
	  }
	  else{
	    q = j;
	  }
 
	  if(i+1 < N){
	    p1 = i+1;
	  }
	  else{
	    p1 = i;
	  }
	  if(j+1 < N){
	    q1 = j+1;
	  }
	  else{
	    q1 = j;
	  }
	  int cnt=0;
	  for(m=p;m<=p1;m++){
	    for(n=q;n<=q1;n++){
	      if(board[m][n] == -2){
		cnt++;
	      }
	    }
	  }
	  if(cnt == (res-48)){
	    for(m=p;m<=p1;m++){
	      for(n=q;n<=q1;n++){
		if(board[m][n] == -2){
		  board[m][n] = -1;
		  Neutralize(m,n);
		  mines_sofar++;
		}
	      }
	    }
	  }
	  if(mines_sofar == M-1 && res == 1){
	    for(m=p;m<=p1;m++){
	      for(n=q;n<=q1;n++){
		if(board[m][n] == -2 && mines_sofar != M){
		  res = Survey(m,n);
		  if(res == 'M'){
		    Neutralize(m,n);
		    mines_sofar++;
		    printf("1.Done\n");
		    fflush(stdout);
		    return 0;
		    board[m][n] = -1;
		  }else{
		    continue;
		  }
		}
	      }
	    }
	    break; 
	  }
	}
      }
    }
  }
  printf("Done\n");
  fflush(stdout);
  return 0;
} 
예제 #4
0
 main()
 {
 int n,m,k;
 //int grid[MAX][MAX]={0};
 scanf("%d%d%d",&n,&m,&k);
 int count=0;
 int i=0,j=0;
 char res;
 int c;
 // int loopx,loopy;
 for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)
 {
 if(!(grid[i][j]))
 {
 res=Survey(i,j);
 grid[i][j]=1;
 if(res=='M')
 {
 count++;
 Neutralize(i,j);
 }
 else if(res=='0')
 {
 // printf("hi");
 if(i-1>=0&&j-1>=0&&i-1<n&&j-1<n) grid[i-1][j-1]=1;
 if(i-1>=0&&j>=0&&i-1<n&&j<n) grid[i-1][j]=1;
 if(i-1>=0&&j+1>=0&&i-1<n&&j+1<n) grid[i-1][j+1]=1;
 if(i>=0&&j-1>=0&&i<n&&j-1<n) grid[i][j-1]=1;
 if(i>=0&&j+1>=0&&i<n&&j+1<n) grid[i][j+1]=1;
 if(i+1>=0&&j-1>=0&&i+1<n&&j-1<n) grid[i+1][j-1]=1;
 if(i+1>=0&&j>=0&&i+1<n&&j<n) grid[i+1][j]=1;
 if(i+1>=0&&j+1>=0&&i+1<n&&j+1<n) grid[i+1][j+1]=1;
 }
 else if(res>='3')
 {
 Neutralize(i+1,j+1);
 Neutralize(i+1,j);
 Neutralize(i,j+1);
 grid[i][j+1]=1;
 grid[i+1][j]=1;
 grid[i+1][j+1]=1;
 count+=3;
 }
 else if((i+1)==n&&res=='1')
 {
 Neutralize(i,j+1);
 grid[i][j+1]=1;
 count++;
  
 }
 /*else if(res>='4')
 {
 Neutralize(i+1,j+1);
 Neutralize(i+1,j);
 Neutralize(i,j+1);
 Neutralize(i+1,j-1);
 grid[i][j+1]=1;
 grid[i+1][j]=1;
 grid[i+1][j+1]=1;
 grid[i+1][j-1]=1;
 count+=4;
  
 }*/
 else{
 if(i>=0&&j+1>=0&&i<n&&j+1<n&&!grid[i][j+1])
 {
 grid[i][j+1]=1;
 res=Survey(i,j+1);
 if(res=='M') {count++; Neutralize(i,j+1);}
 else if(res=='0')
 {
 zero(i,j+1,n);
 }
 }
 if(i+1>=0&&j-1>=0&&i+1<n&&j-1<n&&!grid[i+1][j-1])
 {
 grid[i+1][j-1]=1;
 res=Survey(i+1,j-1);
 if(res=='M') { count++; Neutralize(i+1,j-1);}
 else if(res=='0')
 {
 zero(i+1,j-1,n);
 }
 }
 if(count==m)
 {
 printf("Done");
 return 0;
 }
 if(i+1>=0&&j>=0&&i+1<n&&j<n&&!grid[i+1][j])
 {
 grid[i+1][j]=1;
 res=Survey(i+1,j);
 if(res=='M') {count++; Neutralize(i+1,j); }
 else if(res=='0')
 {
 zero(i+1,j,n);
 }
 }
 if(count==m)
 {
 printf("Done");
 return 0;
 }
 if(i+1>=0&&j+1>=0&&i+1<n&&j+1<n&&!grid[i+1][j+1])
 {
 grid[i+1][j+1]=1;
 res=Survey(i+1,j+1);
 if(res=='M') { count++; Neutralize(i+1,j+1);}
 else if(res=='0')
 {
 zero(i+1,j+1,n);
 }
 }
 }
 }
  
 if(count==m)
 {
 printf("Done");
 return 0;
 }
 }
 }
 }
예제 #5
0
   int main()
	 { int n,m,k; int RAJAT[MAX][MAX]= {0};
	  scanf("%d%d%d",&n,&m,&k); 
	  int count=0; int i=0,j=0; 
	  char res; int c; 
	   for(i=0;i<n;i=i+2)
	    { 
		for(j=0;j<n;j=j+2)
		 { 
		 if(!(RAJAT[i][j]))
		  { 
		  res=Survey(i,j);
		   if (res=='M')
		    { 
			count++;
			 Neutralize(i,j);
			 RAJAT[i][j]=1;
			  }//make it 1
			 else if (res=='0') 
			 { 
			  if (i-1>=0&&j-1>=0&&i-1<n&&j-1<n) 
			  RAJAT[i-1][j-1]=1;
			   if (i-1>=0&&j>=0&&i-1<n&&j<n) RAJAT[i-1][j]=1;
			   if(i-1>=0&&j +1>=0&&i-1<n&&j+1<n) RAJAT[i-1][j+1]=1;//good enough...all 8
			if (i>=0&&j-1>=0&&i<n&&j-1<n) RAJAT[i][j-1]=1; 
			 if(i>=0&&j +1>=0&&i<n&&j+1<n) RAJAT[i][j+1]=1;
			if(i+1>=0&&j-1>=0&&i +1<n&&j-1<n) RAJAT[i +1][j-1]=1;
			 if(i+1>=0&&j>=0&&i +1<n&&j<n) RAJAT[i +1][j]=1; 
			if(i+1>=0&&j+1>=0&&i +1<n&&j+1<n) RAJAT[i +1][j+1]=1; } 
			else if(res=='3')
			{
			if(i>=0&&j +1>=0&&i<n&&j+1<n) {
			RAJAT[i][j+1]=1;
			Neutralize(i,j+1);
			}
			 if(i+1>=0&&j>=0&&i +1<n&&j<n) {
			 RAJAT[i +1][j]=1;
			  Neutralize(i+1,j);
		}
               	if(i+1>=0&&j+1>=0&&i +1<n&&j+1<n) 
				   {
				   RAJAT[i +1][j+1]=1;
				    Neutralize(i+1,j+1);	
				   }	
		
		
		
		
		
				
			}
				else 
				{ 
				if (i-1>=0&&j-1>=0&&i-1<n&&j-1<n&&!RAJAT[i-1][j-1]) 
                     {
					 RAJAT[i-1][j-1]=1; 
                     res=Survey(i-1,j-1); 
                 if (res=='M')
                    {
                      count++; 
					  Neutralize(i-1,j-1);
					  RAJAT[i-1][j-1]=1;
					  }
					  }
               if (i-1>=0&&j>=0&&i-1<n&&j<n&&! RAJAT[i-1][j]) 
                    { RAJAT [i-1][j]=1; 
                       res=Survey (i-1,j);
                  if(res=='M') {count ++;
				  RAJAT[i-1][j]=1;
				   Neutralize(i-1,j);}
   }
                     if(i-1>=0&&j +1>=0&&i-1<n&&j +1<n&&!RAJAT[i-1][j+1]) 
	{                               RAJAT[i-1][j+1]=1; res=Survey(i-1,j+1); 
	                               if (res=='M'){ count++;
								   RAJAT[i-1][j+1]=1;
								    Neutralize(i-1,j+1);}
	}
	                               if (i>=0&&j-1>=0&&i<n&&j-1<n&&! RAJAT[i][j-1])
	  {                               RAJAT[i] [j-1]=1; res=Survey (i,j-1);
	                              if(res=='M') {count ++;
								  RAJAT[i][j-1]=1;
								   Neutralize(i,j-1);}
	   }
	                          if(i>=0&&j +1>=0&&i<n&&j+1<n&&! RAJAT[i][j+1]) { RAJAT[i] [j+1]=1; res=Survey(i,j +1);
		                   if(res=='M') {count++; Neutralize(i,j+1);
						   RAJAT[i][j+1]=1;
						   }
		 } 
		                if(i+1>=0&&j-1>=0&&i +1<n&&j-1<n&&!RAJAT[i +1][j])
		  {                 RAJAT[i+1][j-1] =1; res=Survey(i+1,j-1); 
		                      if(res=='M') { count++; 
							  RAJAT[i+1][j-1]=1;
							  Neutralize(i+1,j-1);}
		  }
		                 if(i+1>=0&&j>=0&&i +1<n&&j<n&&!RAJAT[i+1] [j]) { RAJAT[i+1][j]=1; res=Survey(i+1,j);
		                     if (res=='M') {count++;
							 RAJAT[i+1][j]=1;
							  Neutralize(i+1,j);}
			}
			                  if(i+1>=0&&j+1>=0&&i +1<n&&j+1<n&&!RAJAT[i +1][j+1]) { RAJAT[i+1][j +1]=1; 
			                  res=Survey(i+1,j +1); if(res=='M') 
							  { count++;
							  RAJAT[i+1][j+1]=1;
							   Neutralize(i+1,j+1);}
			 } 
			 } 
			 } 
			 }
			                   if(count==m) { printf("Done"); return 0; }
			   }
			    }