2012 ACM/ICPC Asia Regional Changchun Online
来源:互联网 发布:python wmi 编辑:程序博客网 时间:2024/04/30 08:36
1006
LianLianKan
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
I like playing game with my friends, although sometimes look pretty naive. Today I invent a new game called LianLianKan. The game is about playing on a number stack.
Now we have a number stack, and we should link and pop the same element pairs from top to bottom. Each time, you can just link the top element with the same-value element. After pop them from stack, all left elements will fall down. Although the game seems to be interesting, it's really naive indeed.
To prove I am wisdom among my friends, I add an additional rule to the game: for each top element, it can just link with the same-value element whose distance is less than 5.
Before the game, I want to check whether I have a solution to pop all elements in the stack.
Now we have a number stack, and we should link and pop the same element pairs from top to bottom. Each time, you can just link the top element with the same-value element. After pop them from stack, all left elements will fall down. Although the game seems to be interesting, it's really naive indeed.
To prove I am wisdom among my friends, I add an additional rule to the game: for each top element, it can just link with the same-value element whose distance is less than 5.
Before the game, I want to check whether I have a solution to pop all elements in the stack.
Input
There are multiple test cases.
The first line is an integer N indicating the number of elements in the stack initially. (1 <= N <= 1000)
The next line contains N integers ai indicating the elements from bottom to top. (0 <= ai <= 2,000,000,000)
The first line is an integer N indicating the number of elements in the stack initially. (1 <= N <= 1000)
The next line contains N integers ai indicating the elements from bottom to top. (0 <= ai <= 2,000,000,000)
Output
For each test case, output “1” if I can pop all elements; otherwise output “0”.
Sample Input
21 131 1 121000000 1
Sample Output
100
。
英语烂也有好处啊,less than 是小于,一直以为是小于等于。一不小心就ac了,rp吼吼,简单贪心模拟水水的过了,貌似后来看了下还是偶们学校第一个ac的吼吼,rp万岁
然后剩下四个半小时一题没做出来....实力不济(Y-Y)
#include<stdio.h>#include<string.h>#define begin freopen("a.in","r",stdin); freopen("a.out","w",stdout);#define end fclose(stdin); fclose(stdout);int a[1010],b[1010];int main(){ int i,n,j,dis,top,f; while (scanf("%d",&n)!=EOF) { memset(b,0,sizeof(b)); for (i=1;i<=n;i++) { scanf("%d",&a[i]); b[i]=1; } if (n%2) printf("0\n"); else { top=1; f=0; while (top<n) { for (i=top;i<=n;i++) if (b[i]==1) { j=i; dis=0; while (dis<=5&&j<=n) { if (b[j+1]==1) { ++dis; if (a[i]==a[j+1]&&dis<5) {b[i]=0;b[j+1]=0;f=1;} } ++j; if (f) break; } } if (f) f=0; else break; while (b[top]==0&&top<=n) ++top; } f=1; for (i=1;i<=n;i++) if (b[i]){f=0; break;} printf("%d\n",f); } } return 0;}
- 2012 ACM/ICPC Asia Regional Changchun Online
- 2013 ACM/ICPC Asia Regional Changchun Online
- 2013 ACM/ICPC Asia Regional Changchun Online
- 2013 ACM/ICPC Asia Regional Changchun Online
- 2015 ACM/ICPC Asia Regional Changchun Online
- 2015 ACM/ICPC Asia Regional Changchun Online
- 2012 ACM/ICPC Asia Regional Changchun Online-1001
- 2012 ACM/ICPC Asia Regional Changchun Online-1010
- 2012 ACM/ICPC Asia Regional Changchun Online-1006
- 2012 ACM/ICPC Asia Regional Changchun Online 解题报告
- 2012 ACM/ICPC Asia Regional Changchun Online-1002
- 2012 ACM/ICPC Asia Regional Changchun Online-1011(hdu4277)
- 2012 ACM/ICPC Asia Regional Changchun Online [赛后解题报告]
- 2012 ACM/ICPC Asia Regional Changchun Online-LianLianKan
- HDU4273 Rescue(2012 ACM/ICPC Asia Regional Changchun Online)
- 2013 ACM/ICPC Asia Regional Changchun Online Stone
- 2013 ACM/ICPC Asia Regional Changchun Online hdu Theme Section
- 2015 ACM/ICPC Asia Regional Changchun Online(1002)
- 简单蚁群算法的实现
- 方维分享怎样修改数据库配置
- 如何选择WEB开发语言(转载)
- Blueprint 使用手记
- Maven安装
- 2012 ACM/ICPC Asia Regional Changchun Online
- JAVA--第3周实验--任务2--实现二维数组的一种加法运算(编程思想)
- JDBC开发数据库中大文本以及多媒体文件的操作
- TCP/IP详解(6,7,8)ICMP,Ping,Traceroute,第六七八章笔记整理
- Mysql使用大全-从基础到存储过程
- loadlibrary failed with error 126:找不到指定模块 解决方法
- centos 启用 telnet服务
- strcpy
- SD卡的初始化流程