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