hdoj 4272 LianLianKan 数据太水
LianLianKan
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2884 Accepted Submission(s): 898
like playing game with my friend, although sometimes looks 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 one 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 a wisdom among my friend, 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 6 with it.
Before the game, I want to check whether I have a solution to pop all elements in the stack.
The first line is an integer N indicating the number of elements in the stack initially. (1 <= N <= 1000)
The next line contains N integer ai indicating the elements from bottom to top. (0 <= ai <= 2,000,000,000)
1 1
3
1 1 1
2
1000000 1
0
0
LL a[maxn];
int vis[maxn];
int flag=;
map<int,int> kiss;
int n;
void dfs(int nn,int cur)
{
if(nn>n)
return;
if(vis[nn]==)
dfs(nn+,cur);
if(cur==n)
{
flag=;
return;
}
int m=nn;
REP_1(i,)
{
m++;
while()
{
if(m>n)
return;
if(vis[m]==)
break;
m++;
}
if(a[m]==a[nn])
{
vis[nn]=;
vis[m]=;
dfs(nn+,cur+);
vis[nn]=;
vis[m]=;
}
}
}
int main()
{
while(RD(n)!=-)
{
memset(vis,,sizeof(vis));
kiss.clear();
REP_1(i,n)
{
RD(a[i]);
kiss[a[i]]++;
}
if(n%==)
{
flag=;
printf("0\n");
continue;
}
int flag2=;
REP_1(i,n)
{
if(kiss[a[i]]%==)
{
flag2=;
break;
}
}
if(flag2==)
{
printf("0\n");
continue;
}
//dfs(1,0);
cout<<""<<endl;
} }
hdoj 4272 LianLianKan 数据太水的更多相关文章
- hdu 4940 数据太水...
http://acm.hdu.edu.cn/showproblem.php?pid=4940 给出一个有向强连通图,每条边有两个值分别是破坏该边的代价和把该边建成无向边的代价(建立无向边的前提是删除该 ...
- POJ 2528(线段树+离散化+特殊离散化)网上博客很少有人真正写对!!! 是POJ数据太水...
Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral electio ...
- 关于chart.js 设置canvas的宽度为父级元素的宽度的百分百 以及 X轴上面刻度数据太多如何处理
今天在做一个数据统计的界面的时候,需要做折线统计图,在网上找了一圈发现数据统计的插件还是不少的,本着轻量级的的原则选择了Chart.js,后来在做的过程中便遇到两个问题,以此记录下来,和刚刚接触前端的 ...
- 解决持久化数据太大,单个节点的硬盘无法存储的问题;解决运算量太大,单个节点的内存、CPU无法处理的问题
需要学习的技术很多,要自学新知识也不是一件容易的事,选择一个自己比较感兴趣的会是一个比较好的开端,于是,打算学一学分布式系统. 带着问题,有目的的学习,先了解整体架构,在深入感兴趣的细节,这是我的计划 ...
- ireport报表制作, 当一个字段显示的数据太多时(数据过长),则需要自动换行
1.当一个字段显示的数据太长,一个表格放不下,则需要自动换行,选中要更改的表格(要显示动态内容的字段),设置属性Stretch with overflow 为钩选状态. 未勾选之前: 勾选之后: 2. ...
- 有些有IP的项目,公司不至于测试不行砍项目,但是会砍项目组,把IP收回交给别的团队做(因为一旦一测数据太差,公司(投资人)会判断在二测的时候数据能提升到什么样。说白了就是历史信用问题)
作者:匿名用户链接:https://www.zhihu.com/question/309778033/answer/579761064来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...
- echart-折线图,数据太多想变成鼠标拖动和滚动的效果?以及数据的默认圈圈如何自定义圆圈的样式
1.数据太多怎么办???想拖拽,想滑动 dataZoom: [ { type: 'slider', } ] dataZoom: [ { type: 'inside', }] 两种功能都需要,还想调样 ...
- echarts中饼状图数据太多进行翻页
echarts饼状图数据太多 echarts 饼状图内容太多怎么处理 有些时候,我们饼状图中echarts的数据可能会很多. 这个时候展示肯定会密密麻麻的.导致显示很凌乱 我们需要'翻页'类似表格展示 ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
随机推荐
- 关于app的cpu占用率想到的几个问题
1.top 命令获取的cpu是手机瞬间的cpu 2.dumpsys获取的是一段时间cpu的平均值?那么这段时间是指哪段,从哪开始到什么时候结束? 3.如果想测试app某操作下的cpu占用情况时候.应该 ...
- bzoj 1034 泡泡堂BNB
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1034 题解: 很明显的贪心,读过田忌赛马的典故就很容易能想出来,分成三种情况讨论: < ...
- Deploy Openstack all-in-one Shell Script
Deploy Openstack all-in-one Shell Script At present(2015/10), the RDO deploment method can only inst ...
- nvm npm node.js的关系
nvm npm node.js都是用来构建reactNativ的项目 nvm管理node.j和npm版本的 node.js管理reactNative开发中所需要的代码库的 npm管理对应node ...
- idea心得
概述 Intellij IDEA真是越用越觉得它强大,它总是在我们写代码的时候,不时给我们来个小惊喜.出于对Intellij IDEA的喜爱,我决定写一个与其相关的专栏或者系列,把一些好用的Intel ...
- git clone命令使用
git clone命令使用 分类: 项目构建2013-06-26 15:43 38660人阅读 评论(2) 收藏 举报 GitClone git clone 命令参数: usage: git clon ...
- 《Javascript启示录》要点汇总
前言:本文是阅读<Javascript启示录>后的一个读书笔记,对本书的要点进行了一个归纳,不是原创内容哦.要想详细了解相关内容,请阅读原书. 对象是由存储值的已命名属性组成的. Java ...
- Python基础 - 正则表达式
Python自带正则表达式模块,即re模块. 导入正则模块: import re 用dir()函数查看re模块内的属性和方法: dir(re)
- 由结构体成员地址计算结构体地址——list_entry()原理详解
#define list_entry(ptr, type, member) container_of(ptr, type, member) 在进行编程的时候,我们经常在知道结构体地址的情况下,寻找其中 ...
- Oracle学习笔记:11g服务介绍及哪些服务必须开启?
由于工作环境中oracle版本为10g,不支持行转列函数pivot,特在自己电脑上安装了oracle 11g,但因为不经常使用,便把服务自动启动给关闭了,只在需要使用时手动启动,因此记录一下需要启动的 ...