Uva11464 even matrix, reasoning

Source: Internet
Author: User

 

I have made a few so-called water questions for the provincial competition tomorrow. Unfortunately, this question has been wrong for a long time because of the output ,,,

 

If all the locations of the enumerated matrix are changed, the time complexity cannot be tolerated.

What I learned from this question is:
1. First simulate the problem, and then try to find the rule. The rule of this question is: once the first line is determined, the entire matrix can be determined. Therefore, the first line can be enumerated.

2. if else must clarify all the logic of the situation. This Debug case has changed slightly, and it has been WA for a long time, and the code has been pasted in the back. When debugging is used, it is likely that the difference between old ideas and new ideas produces new bugs.

 

 

# Include
 
  
# Include
  
   
# Include using namespace std; const int MAXN = 20; // const int INF = 0x3fffffff; 999 const int INF = 1000000000; int n, a [MAXN] [MAXN], B [MAXN] [MAXN]; int Judge (int m) {// memset (B, 0, sizeof (B); int tmp = 0; for (int I = 0; I
   
    
= 0) sum + = B [I-1] [J-1]; if (j + 1
    
     
= 0) sum + = B [I-2] [j]; if (sum % 2) {if (! B [I] [j]) {B [I] [j] = 1; tmp ++;} else return INF ;}// this method is incorrect, because none of the above steps detect the last line, test the last line */for (int I = 0; I
     
      
= 0) sum + = B [N-2] [I]; if (I> 0) sum + = B [n-1] [I-1]; if (I + 1
      
       
# Include
        
         
# Include
         
          
# Include using namespace std; const int MAXN = 20; // const int INF = 0x3fffffff; 999 const int INF = 99999; int n, a [MAXN] [MAXN], B [MAXN] [MAXN]; int Judge (int m) {// memset (B, 0, sizeof (B); int tmp = 0; for (int I = 0; I
          
           
= 0) sum + = B [I-1] [J-1]; if (j + 1
           
            
= 0) sum + = B [I-2] [j]; if (sum % 2) {if (! B [I] [j]) {B [I] [j] = 1; tmp ++ ;} // else. This is so awesome that I didn't find this bug. // return INF;} else {if (B [I] [j] = 1) return INF ;}/// this statement is incorrect, because/* the above steps do not detect the last line, and test the last line */for (int I = 0; I
            
             
= 0) sum + = B [N-2] [I]; if (I> 0) sum + = B [n-1] [I-1]; if (I + 1
             
              

 

Related Article

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.