LA 2995 Image Is Everything
2016-07-04 15:01
375 查看
题目
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26450题解
其实这道题只要看了题解就好简单的样子,注意学习他的化简代码的神奇能力和分析问题化简为繁的神奇能力代码
#include<queue> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define rep(i,x,y) for(int i=x;i<=y;i++) using namespace std; const int maxn=10+5; const int maxm=10; char mx[maxm][maxn][maxn],cell[maxn][maxn][maxn]; int n; inline char input() { char ch=getchar(); while(ch==' '||ch=='\n') ch=getchar(); return ch; } inline void get(int k,int i,int j,int dep,int &x,int &y,int &z) { if(k==1) {x=i; y=j; z=dep; return ;} if(k==2) {x=i; y=dep; z=n+1-j; return ;} if(k==3) {x=i; y=n+1-j; z=n+1-dep;return ;} if(k==4) {x=i; y=n+1-dep;z=j; return ;} if(k==5) {x=dep;y=j; z=n+1-i; return ;} x=n+1-dep;y=j;z=i; } int x,y,z; inline void solve() { rep(X,1,n) rep(Y,1,n) rep(Z,1,n) cell[X][Y][Z]='#'; rep(i,1,n) rep(k,1,6) rep(j,1,n) { mx[k][i][j]=input(); if(mx[k][i][j]=='.') rep(dep,1,n) { get(k,i,j,dep,x,y,z); cell[x][y][z]='.'; } } int done=1; while(done) { done=0; rep(k,1,6) rep(i,1,n) rep(j,1,n) if(mx[k][i][j]!='.') rep(dep,1,n) { get(k,i,j,dep,x,y,z); char &Cell=cell[x][y][z]; if(Cell=='.') continue; if(Cell=='#') { Cell=mx[k][i][j];break; } if(Cell==mx[k][i][j]) break; Cell='.'; done=1; } } int ans=0; rep(X,1,n) rep(Y,1,n) rep(Z,1,n) if(cell[X][Y][Z]!='.') ans++; printf("Maximum weight: %d gram(s)\n",ans); return ; } inline void debug() { int k,i,j,dep; scanf("%d%d%d%d%d",&n,&k,&i,&j,&dep); get(k,i,j,dep,x,y,z); printf("x=%d y=%d z=%d",x,y,z); return ; } int main() { while(scanf("%d",&n)==1&&n) solve(); // debug(); return 0; }
相关文章推荐
- rsyslog研究
- 几个 Context 上下文的区别
- POJ1850&&POJ1496
- HDU 1241 Oil Deposits【简单DPS搜索】
- netcat使用
- dedecms 常用标签
- Radius 远程用户拨号认证系统
- Redis安装+主从配置 过程中 的几个小 Tips
- 【RT-Thread学习笔记 2】RT-Thread的线程(任务)处理
- 利用Digester实现xml和bean之间的转换(二)
- python中几种不同类型的参数的区分及其定义时的顺序
- kafka性能参数和压力测试揭秘
- 参数传递
- app检测更新
- LeetCode 342. Power of Four
- second blog
- android:clipToPadding和android:clipChildren
- leetcode 338. Counting Bits
- 开发者最常用的 8 款 Sublime text 3 插件
- xmlns:android="http://schemas.android.com/apk/res/android的作用