There are n countries that require you to design a building and divide rooms for these n countries, requiring that the country's rooms must be interconnected, and that one room must be adjacent to each of the two countries.
Problem-solving ideas: Just beginning to think very complex, by the example to mislead, plus test instructions didn't judge, thought room adjacent must on the same floor ... I've been in this hole for a long time
Only need to design two layers, each country occupies the first tier of each row, the second floor of each column, so that both Unicom and adjacent to the
#include <cstdio> #include <cstring> #define MAXN 60char ans[maxn]= " ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ "; int main () { int n,mark=1; while (scanf ("%d", &n)!=eof) { printf ("2%d%d\n", n,n); for (int i=0;i<n;i++) { for (int j=0;j<n;j++) printf ("%c", Ans[i]); printf ("\ n"); } printf ("\ n"); for (int i=0;i<n;i++) { for (int j=0;j<n;j++) printf ("%c", Ans[j]); printf ("\ n");} } return 0;}
Uva1605-building for UN (construction)