uvaoj 1030 - Image Is Everything
来源:互联网 发布:淘宝达人如何大v认证 编辑:程序博客网 时间:2024/06/06 05:18
总结:
1.以前看过汝佳哥源代码,没有打在电脑里提交,自以为会了,最近重新做题的时候才发现原来只是看懂了,自己并不能很快的思考出来这个问题,以后凡是碰到代码,尽所能付诸于实践!以写代码,写博客的形式,以检验是否真的明白了
2.感觉自己快要完全想出解决方案的时候,没有坚持思考完就去看汝佳哥的方法了,以后还是要,即使觉得自己应该没问题的时候,也要先自己完整的想出解题策略,再看大神的代码,进行学习
3.有一个地方汝佳哥写的特别棒,就是碰到颜色冲突的时候,并不是直接跳出循环,重新搜索,而是继续尝试将后面的错误一并找出来,感觉这样算法的速度会快一些!也许这个思维是一个习惯问题,就像平时思考问题,总是思考的差不多,或者思考出来了就浅尝辄止,其实应该继续深入思考(即使是对于题目没有问到的,或者老师没有布置到的内容)。
#include<cstdio>#include<cstring>#include<iostream>using namespace std;#define MAXN 12#define F(i,n) for(int i = 0;i < (n);i++)char view[6][MAXN][MAXN],pos[MAXN][MAXN][MAXN];int x,y,z,n;void get(int k,int i,int j,int l,int &x,int &y,int &z){ if(k == 0){x = j,y = n - l - 1,z = n - i - 1;} else if(k == 1){x = l,y = j,z = n - i - 1;} else if(k == 2){x = n - j - 1,y = l,z = n - i - 1;} else if(k == 3){x = n - l - 1,y = n - j - 1,z = n - i - 1;} else if(k == 4){x = j,y = i,z = n - l - 1;} else {x = j,y = n - i - 1,z = l;}}char get_char(){ while(1) { char c = getchar(); if((c >= 'A' && c <= 'Z') || c == '.')return c; }}int main(){ while(cin >> n && n) { F(i,n)F(k,6)F(j,n)view[k][i][j] = get_char(); F(k,n)F(i,n)F(j,n)pos[k][i][j] = '#'; F(k,6)F(i,n)F(j,n)if(view[k][i][j] == '.')F(l,n) { get(k,i,j,l,x,y,z); pos[z][y][x] = '.'; } while(1) { bool done = true; F(k,6)F(i,n)F(j,n)if(view[k][i][j] != '.')F(l,n) { get(k,i,j,l,x,y,z); if(pos[z][y][x] == '.')continue; else if(pos[z][y][x] == '#') { pos[z][y][x] = view[k][i][j]; break; } else if(pos[z][y][x] == view[k][i][j])break; else if(pos[z][y][x] != view[k][i][j]) { pos[z][y][x] = '.'; done = false; } } if(done)break; } int cnt = n * n * n; F(k,n)F(i,n)F(j,n)if(pos[k][i][j] == '.')cnt--; printf("Maximum weight: %d gram(s)\n",cnt); }}
0 0
- uvaoj 1030 - Image Is Everything
- 1030 - Image Is Everything
- Uva-1030-Image Is Everything
- 1030 - Image Is Everything (贪心)
- Uva 1030 - Image Is Everything
- UVA 1030 Image Is Everything
- UVA-1030-Image Is Everything
- UVA 1030 Image Is Everything
- Uva 1030 Image Is Everything
- uva 1030 - Image Is Everything(乱搞)
- UVA 1030 - Image Is Everything(贪心枚举)
- Image Is Everything
- Image Is Everything
- LA2995- Image Is Everything
- uva1030 Image Is Everything
- Image Is Everything UVALive
- Image Is Everything(立方体成像)
- la 2995 Image is everything
- 有关UIView、subview的几个基础知识点-IOS开发 (实例)
- Virtual 下安装CentOs6.4
- 详解JDBC与Hibernate区别
- 最大值栈和最大值队列(Tsinghua OJ,PA2)
- 大数能否被小数整除 ACM
- uvaoj 1030 - Image Is Everything
- 源码阅读----网络请求
- 解决vim 中文乱码
- Android 自定义字体
- Codeforces Round #327 (Div. 2) B. Rebranding
- Codeforces Round #327 (Div. 2) C. Median Smoothing 暴力
- centos6.6中mysql5.6主从复制
- 缓存机制
- [iOS进阶]Reveal使用技巧