Zoj 2714 ultraviolet A la 2995 image is everything wit

Source: Internet
Author: User

Question:

An N * n cube, each unit lattice may be empty, or a solid color cube, giving you six views, you can see and wear. otherwise, an uppercase letter represents the color. Maximum possible volume.

Analysis:

A final question is like a question that describes the wit level. I am not smart enough .. I don't know how to write the question after reading the question .. Finally, I refer to the code of the white book training guide. The practice is as follows:

Create a 3-dimensional array to store the entire cube. First, for the items that can be viewed, the slide is empty. The next step is a process of dyeing and determining the contradiction. Each position on all sides of the cycle is used to dye the corresponding position of the cube. If there is a conflict, the position is empty and is always deleted.

 

 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5  6 char read(){ 7     char ret; 8     while(1){ 9         ret = getchar();10         if (ret == ‘.‘ || (ret >= ‘A‘ && ret <= ‘Z‘)) return ret;11     }12 }13 int n;14 void getp(int id, int r, int c, int d, int &x, int &y, int &z){15     if (id == 0) x = n-1-d, y = c, z = n-1-r;16     if (id == 1) x = c, y = d, z = n-1-r;17     if (id == 2) x = d, y = n-1-c, z = n-1-r;18     if (id == 3) x = n-1-c, y = n-1-d, z = n-1-r;19     if (id == 4) x = r, y = c, z = n-1-d;20     if (id == 5) x = n-1-r, y = c, z = d;21 }22 int x, y, z;23 char pos[15][15][15], view[6][15][15];24 int main()25 {26     while(scanf("%d", &n) && n)27     {28         for (int j = 0; j < n; j++)29             for (int i = 0; i < 6; i++)30                 for (int k = 0; k < n; k++)31                     view[i][j][k] = read();32         for (int i = 0; i < n; i++)33             for (int j = 0; j < n; j++)34                 for (int k = 0; k < n; k++)35                     pos[i][j][k] = ‘#‘;36         for (int i = 0; i < 6; i++)37             for (int j = 0; j < n; j++)38                 for (int k = 0; k < n; k++) if (view[i][j][k] == ‘.‘){39                     for (int p = 0; p < n; p++){40                         getp(i, j, k, p, x, y, z);41                         pos[x][y][z] = ‘.‘;42                     }43                 }44         bool flag = true;45         while(flag){46             flag = false;47             for (int i = 0; i < 6; i++)48                 for (int j = 0; j < n; j++)49                     for (int k = 0; k < n; k++) if (view[i][j][k] != ‘.‘){50                         for (int p = 0; p < n; p++){51                             getp(i, j, k, p, x, y, z);52                             if (pos[x][y][z] == ‘.‘) continue;53                             if (pos[x][y][z] == ‘#‘){54                                 pos[x][y][z] = view[i][j][k];55                                 break;56                             }57                             if (pos[x][y][z] == view[i][j][k]) break;58                             pos[x][y][z] = ‘.‘;59                             flag = true;60                         }61                     }62         }63         int ans = 0;64         for (int i = 0; i < n; i++)65             for (int j = 0; j < n; j++)66                 for (int k = 0; k < n; k++)67                     if (pos[i][j][k] != ‘.‘) ans++;68         printf("Maximum weight: %d gram(s)\n", ans);69     }70     return 0;71 }

 

Zoj 2714 ultraviolet A la 2995 image is everything wit

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.