LianLianKan

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2884    Accepted Submission(s): 898

Problem Description
I
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.
 
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 integer 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
2
1 1
3
1 1 1
2
1000000 1
 
Sample Output
1
0
0
 
 
题意
给你一个队列,然后每个子可以和距离为以内的子连接,然后这两个子都pop,然后问你,是否这个队列能够全部pop掉
 
 
题解
数据太水了,判一判子的个数是否为偶数,然后再判断是否每一类都是偶数,然后直接输出1,然后就A了= =
标答应该是一个状态压缩DP
 
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 数据太水的更多相关文章

  1. hdu 4940 数据太水...

    http://acm.hdu.edu.cn/showproblem.php?pid=4940 给出一个有向强连通图,每条边有两个值分别是破坏该边的代价和把该边建成无向边的代价(建立无向边的前提是删除该 ...

  2. POJ 2528(线段树+离散化+特殊离散化)网上博客很少有人真正写对!!! 是POJ数据太水...

    Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral electio ...

  3. 关于chart.js 设置canvas的宽度为父级元素的宽度的百分百 以及 X轴上面刻度数据太多如何处理

    今天在做一个数据统计的界面的时候,需要做折线统计图,在网上找了一圈发现数据统计的插件还是不少的,本着轻量级的的原则选择了Chart.js,后来在做的过程中便遇到两个问题,以此记录下来,和刚刚接触前端的 ...

  4. 解决持久化数据太大,单个节点的硬盘无法存储的问题;解决运算量太大,单个节点的内存、CPU无法处理的问题

    需要学习的技术很多,要自学新知识也不是一件容易的事,选择一个自己比较感兴趣的会是一个比较好的开端,于是,打算学一学分布式系统. 带着问题,有目的的学习,先了解整体架构,在深入感兴趣的细节,这是我的计划 ...

  5. ireport报表制作, 当一个字段显示的数据太多时(数据过长),则需要自动换行

    1.当一个字段显示的数据太长,一个表格放不下,则需要自动换行,选中要更改的表格(要显示动态内容的字段),设置属性Stretch with overflow 为钩选状态. 未勾选之前: 勾选之后: 2. ...

  6. 有些有IP的项目,公司不至于测试不行砍项目,但是会砍项目组,把IP收回交给别的团队做(因为一旦一测数据太差,公司(投资人)会判断在二测的时候数据能提升到什么样。说白了就是历史信用问题)

    作者:匿名用户链接:https://www.zhihu.com/question/309778033/answer/579761064来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...

  7. echart-折线图,数据太多想变成鼠标拖动和滚动的效果?以及数据的默认圈圈如何自定义圆圈的样式

    1.数据太多怎么办???想拖拽,想滑动 dataZoom: [ { type: 'slider', } ] dataZoom: [ { type: 'inside',  }] 两种功能都需要,还想调样 ...

  8. echarts中饼状图数据太多进行翻页

    echarts饼状图数据太多 echarts 饼状图内容太多怎么处理 有些时候,我们饼状图中echarts的数据可能会很多. 这个时候展示肯定会密密麻麻的.导致显示很凌乱 我们需要'翻页'类似表格展示 ...

  9. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

随机推荐

  1. Method for balancing binary search trees

    Method for balancing a binary search tree. A computer implemented method for balancing a binary sear ...

  2. socket系统调用

    SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol) { int retval; struct socket *sock; in ...

  3. Linux USB驱动学习总结(一)---- USB基本概念及驱动架构

    USB,Universal Serial Bus(通用串行总线),是一个外部总线标准,用于规范电脑与外部设备的连接和通讯.是应用在PC领域的接口技术.USB接口支持设备的即插即用和热插拔功能.USB是 ...

  4. 【Linux】Linux基本命令扫盲【转】

    转自:http://www.cnblogs.com/lcw/p/3762927.html [VI使用] 1.在命令行模式     :在vi编辑器中将光标放在函数上,shift + k 可直接man手册 ...

  5. nginx配置location总结及rewrite规则写法【转】

    转自 nginx配置location总结及rewrite规则写法 | Sean's Noteshttp://seanlook.com/2015/05/17/nginx-location-rewrite ...

  6. 数据科学实战手册(R+Python)书中引用资料网址

    本文会持续将<数据科学实战手册(R+Python)>一书中的附带参考资料网址手打出来, 方便访问. 由于书中的参考资料网址太多, 这个文档将可能花费一段时间才能完成. 第一章 P7  Rs ...

  7. ls和cd命令详解

    ls命令 命令功能: ​ 列出当前目录下或者指定目录下的所有文件和目录,ls是list的缩写. 命令语法: ls [选项][目录名 ] #注:[ ]中的内容为非必选项 命令选项: | 选项 | 含义 ...

  8. [转]python与numpy基础

    来源于:https://github.com/HanXiaoyang/python-and-numpy-tutorial/blob/master/python-numpy-tutorial.ipynb ...

  9. 简单计算器的C实现-函数指针,main函数传参

    /** 程序功能:简单计算器,实现加减乘除平方* 作者版本日期:2015.11.08 zhouhb OK* 源代码:李明 <新概念C语言培训>第33集 C语言Shell命令解释器的实现* ...

  10. 洛谷P1186玛丽卡

    传送门啦 先跑一遍最短路,将最短路的路径记录下来,然后枚举每一条最短路的边,将其断掉,记录此时的1-n的时间,取其中最大的一个时间即为所求. (通过 $ cut[][] $ 和 $ f[] $ 进行操 ...