Sdust 2410 Mine Number

Source: Internet
Author: User

I saw 3 of these questions today. Enumerate the first line

1#include <cstdio>2#include <cstring>3#include <iostream>4#include <algorithm>5#include <cmath>6#include <queue>7#include <stack>8#include <vector>9#include <map>Ten#include <string> One #defineMaxn A #defineInf - using namespacestd; -typedefLong LongLL; the intN,m,flag; -  - intnum1[ +][ +],num2[ +][ +]; - intGet_sum (intIintj) + { -     inttem=Num2[i][j]; +     if(i>0) Atem+=num2[i-1][j]; at     if(j<m-1) -tem+=num2[i][j+1]; -     if(j>0) -tem+=num2[i][j-1]; -     returntem; - } in intCheckintx) - { to     intans=num2[0][x]; +     if(x) -ans+=num2[0][x-1]; the     if(x<m-1) *ans+=num2[0][x+1]; $     if(ans==num1[0][x] | | ans+1==num1[0][x])Panax Notoginseng         return true; -     return false; the } + intPuan (ints) A { the      for(intj=0; j<m;j++) +     { -         if((s& (1<<J ))) $num2[0][j]=1; $         Else -num2[0][j]=0; -     } the     if(n==1) -     {Wuyi          for(intI=0; i<m;i++) the             if(Get_sum (0, i)!=num1[0][i]) -               return 0; Wu         return 1; -     } About      for(intI=0; i<m;i++) $     { -         if(!Check (i)) -             return 0; -     } A      for(intI=1; i<n;i++) +          for(intj=0; j<m;j++) the     { -         if(Get_sum (i1, j) ==num1[i-1][j]) $num2[i][j]=0; the         Else if(Get_sum (i1, j) +1==num1[i-1][j]) thenum2[i][j]=1; the         Else the             return 0; -  in     } the      for(intI=0; i<m;i++) the         if(Get_sum (n1, i)!=num1[n-1][i]) About           return 0; the     return 1; the } the intMain () + { -  the     Charstr[ -];Bayi     intT; the      while(SCANF ("%d", &t)! =EOF) the     { -          for(intIi=1; ii<=t; ii++) -         { thescanf"%d%d",&n,&m); the              for(intI=0; i<n; i++) the             { thescanf"%s", str); -                  for(intj=0; j<m; J + +) thenum1[i][j]=str[j]-'0'; the             } the 94              for(intI=0; i< (1&LT;&LT;M); i++) the             { the                 if(Puan (i)) the                    Break;98             } Aboutprintf"Case %d:\n", ii); -              for(intI=0; i<n; i++)101             {102                  for(intj=0; j<m; J + +)103                 {104                     if(Num2[i][j]) theprintf"*");106                     Else107printf".");108                 }109printf"\ n"); the             }111         } the     }113  the     return 0; the}

Sdust 2410 Mine Number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.