UVALive 6277 - Addictive Bubbles (模拟)
来源:互联网 发布:私募通数据库 编辑:程序博客网 时间:2024/06/08 02:20
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4288
题意:一个h*w的图,有c中颜色,每次会消去相邻的相同颜色的那几个块,给你每种颜色的数量,让求出这个图
思路:每次消相同,那么我们就把相同颜色的放在一起就可以了,可以利用图的S型的转弯赋值,类似于蛇形填数
ac代码:
#include<stdio.h>#include<math.h>#include<string.h>#include<stack>#include<set>#include<queue>#include<vector>#include<iostream>#include<algorithm>#define MAXN 1010000#define LL long long#define ll __int64#define INF 0xfffffff#define mem(x) memset(x,0,sizeof(x))#define PI acos(-1)using namespace std;int gcd(int a,int b){return b?gcd(b,a%b):a;}LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}//headint a[11][11];int color[11];int main(){ int h,w,c,i,j; while(scanf("%d%d%d",&h,&w,&c)!=EOF) { for(i=1;i<=c;i++) scanf("%d",&color[i]); int x=1,y=1,dir=1; for(i=1;i<=c;i++) { while(color[i]) { a[x][y]=i; color[i]--; if(x>=1&&x<=h&&y+dir>=1&&y+dir<=w) y+=dir; else { dir=dir==1?-1:1; x++; } } } for(i=1;i<=h;i++) { for(j=1;j<=w;j++) printf("%d",a[i][j]); printf("\n"); } } return 0;}
0 0
- UVALive 6277 - Addictive Bubbles (模拟)
- UVALive 3497 brainfuck [模拟]
- UVALive 4723 水模拟
- UVALive 6833 (模拟 水~)
- UVALive 7503--模拟
- UValive 7269 (模拟)
- UVALive 6833【模拟】
- UVALive 7327【模拟】
- UVALive 7608Robot(模拟)
- UVALive 7752 模拟
- 【模拟】 UVALive 4168 Lampyridae Teleportae
- UvaLive--6664--Clock Hands【模拟】
- UVALive 4887 Soccer 状压+模拟
- UVALive 3971 Assemble(模拟 + 二分)
- UVALive 6833Miscalculation (模拟)
- UVALive - 6269 Digital Clock 模拟
- UVALive 5873 - Tree Inspections 【模拟】
- uvalive 4254(二分+模拟)
- 第10、11周-程序阅读补充(1)
- 学习JavaScript应该尽早知道的几个技巧
- Android通知之Notification的用法剖析
- tomcat性能调优
- SiteWhere如何连接MongoDB
- UVALive 6277 - Addictive Bubbles (模拟)
- 获取数组的最小值
- 决策树二
- 1004
- Pascal's Triangle II
- 【一天一道LeetCode】#51. N-Queens
- tableViewCell、collectionViewCell、组头组尾等总结
- 自定义View系列教程04--Draw源码分析及其实践
- Java并发编程:线程池的使用