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;
} }

最新文章

  1. PHP的函数应用
  2. HTML5之语义标签
  3. Groovy 处理 XML
  4. 分享Kali Linux 2016.2第49周虚拟机
  5. 使用linux mint 安装无线网卡驱动
  6. IOS基础之 (一) OC基础语法
  7. PocketSphinx语音识别和turtlebot的语音控制--18
  8. C语言中access、_mkdir、sprintf、 fopen、fwrite函数
  9. Qualcomm device使用ION memory manager取代PMEM
  10. 不再让内容把td撑开
  11. ruby的gem和boundle安装解决办法
  12. WebX配置文件、启动与响应流程
  13. 嵌入式linux加载引导内核和根文件系统的方法
  14. BZOJ 2726: [SDOI2012]任务安排( dp + cdq分治 )
  15. JarSearch
  16. android studio布局文件/XML怎么代码补全
  17. [个人小工具]清除SVN控制
  18. UWP 手绘视频创作工具技术分享系列 - 位图的绘制
  19. LeetCode 162. Find Peak Element (找到峰值)
  20. 使用chan的时候选择对象还是指针

热门文章

  1. Jenkins远程调度Shell命令
  2. listen系统调用
  3. numpy细碎知识点
  4. Python缓存技术,装x新高度。
  5. trace spring
  6. mysql高可用架构 -&gt; MHA配置binlog-server-06
  7. 微软Holographic将更名为Windows Mixed Reality
  8. 前端程序员必知的30个Chrome扩展-[转载]
  9. manacher模板
  10. Asp.net MVC NPOI导出Excel