首页 > 代码库 > LA2995 Image Is Everything
LA2995 Image Is Everything
很有助于思考的模拟题
#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <algorithm>using namespace std;const int maxn = 15;const int maxv = 1005;const int mod = 1e9+7;const int INF = 0x3f3f3f3f;typedef long long LL;char s[7][maxn][maxn];char pos[maxn][maxn][maxn];int n;void get_pos(int k,int i,int j,int d,int &x,int &y,int &z){ if(k==0){x = j;y = n-d-1;z = n-i-1;} if(k==1){x = d;y = j;z = n-i-1;} if(k==2){x = n-j-1;y = d;z = n-i-1;} if(k==3){x = n-d-1;y = n-j-1;z = n-i-1;} if(k==4){x = j;y = i;z = n-d-1;} if(k==5){x = j;y = n-i-1;z = d;}}int main(){// freopen("in.txt","r",stdin);// freopen("out.txt","w",stdout); while(~scanf("%d",&n) && n) { for(int i = 0;i<n;++i) for(int j = 0;j<6;++j) scanf("%s",s[j][i]); for(int i = 0;i<n;++i) for(int j = 0;j<n;++j) for(int k = 0;k<n;++k) pos[i][j][k] = ‘#‘; for(int k = 0;k<6;++k) for(int i = 0;i<n;++i) for(int j = 0;j<n;++j)if(s[k][i][j]==‘.‘) { for(int l = 0;l<n;++l) { int x,y,z; get_pos(k,i,j,l,x,y,z); pos[x][y][z] = ‘.‘; } } while(1) { int ok = 1; for(int k = 0;k<6;++k) for(int i = 0;i<n;++i) for(int j = 0;j<n;++j) for(int l = 0;l<n;++l) { int x,y,z; get_pos(k,i,j,l,x,y,z); if(pos[x][y][z]==‘.‘)continue; if(pos[x][y][z]==‘#‘){pos[x][y][z] = s[k][i][j];break;} if(pos[x][y][z]==s[k][i][j])break; pos[x][y][z] = ‘.‘; ok = 0; } if(ok)break; } int ans = 0; for(int i = 0;i<n;++i) for(int j = 0;j<n;++j) for(int k = 0;k<n;++k) if(pos[i][j][k]!=‘.‘)ans++; printf("Maximum weight: %d gram(s)\n",ans); } return 0;}
LA2995 Image Is Everything
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。