"Link" I am the link, point me:)
Test instructions
Enter the test instructions here
Exercises
A square is preprocessed first.
You can then enumerate the coordinates of the upper-left corner of the newly added square each time.
Pay attention to the rules of the overlay, control it.
Then the violent judgments are the same.
Violent backtracking (only with a square area of backtracking)
Code
/*1.Shoud It use long long?2.Have ever test several sample (at least therr) yourself?3.Can You promise the solution are right? At Least,the main ideal4.use the puts ("") or Putchar () or printf and such things?5.init The used array or any value?6.use error max_value?7.use scanf instead of cin/cout?8.whatch out the detail input require*//*Be sure to write the idea here and then hit the code!!!*/#include <bits/stdc++.h>using namespaceStdConst intN =Ten;Const intM =5;CharS[n+5][n+5],now[n+5][n+5];CharSquare[m+5][m+5];voidInit () { for(inti =0; I <3; i++) for(intj =0;j<5; j + +) Square[i][j] =' '; for(inti =0; I <2; i++) Square[i+1][0] = Square[i+1][4] ='|'; for(intj =1; J <5; j+=2) square[0][j]=square[2][J] ='_';}voidSet (intXintY) { for(inti =0; I <3; i++) for(intj =0; J <5; j + +) {if(i<=0&& now[i+x][j+y]!=' '&& square[i][j]==' ')Continue; Now[i+x][j+y] = Square[i][j]; } for(inti =1; I <2; i++) for(intj =1;j<4; j + +) Now[i+x][j+y] =' ';}BOOLOk () { for(inti =0; I <5; i++) for(intj =0; J <9; j + +)if(Now[i][j]!=s[i][j])return false;return true;}voidOut () { for(inti =0; I <5; i++) { for(intj =0; J <9; j + +) cout <<now[i][j]; cout << Endl; } cout << Endl;}BOOLDfsintDEP) {if(Dep >1&& OK ())return true;if(DEP >=7)return false;intTemp[m+5][m+5]; for(inti =0; I <3; i++) { for(intj =0; J <5; j+=2){ for(intK =0; k <3; k++) for(intL =0; l <5; l++) Temp[k][l] = Now[k+i][l+j]; Set (I,J);if(Dfs (DEP+1))return true; for(intK =0; k <3; k++) for(intL =0; l <5; l++) Now[k+i][l+j] = Temp[k][l]; } }return false;}intMain () {#ifdef Local_defineFreopen ("Rush_in.txt","R", stdin);#endifIos::sync_with_stdio (0), Cin.tie (0); Init ();intKase =0; while(1){ for(inti =0; I <5; i++) {Cin.getline (s[i], the);if(s[i][0]==' 0 ')return 0; } for(inti =0;i<5; i++) for(intj =0; J <9; j + +) Now[i][j] =' ';if(Dfs (1) {cout <<"Case"<<++kase<<": Yes"<<endl; }Else{cout <<"Case"<<++kase<<": No"<<endl; } }return 0;}
"Exercise 7-6 UVA-12113" overlapping squares