博客
关于我
CodeForces - 1330B Dreamoon Likes Permutations
阅读量:331 次
发布时间:2019-03-04

本文共 1749 字,大约阅读时间需要 5 分钟。

CodeForces - 1330B Dreamoon Likes Permutations

在这里插入图片描述
注意点:当输出的答案前半段与后半段相等时,只算一个(卡死我个菜鸡了)

ac代码:

#include
#include
#include
using namespace std;const int maxn=2e5+7;int a[maxn]={ };bool b[maxn]={ };int mx,n,l1,l2;bool jg1(){ memset(b,0,sizeof b); for(int i=1;i<=l1;i++) { b[a[i]]=1; } for(int i=1;i<=l1;i++) { if(b[i]==0) return 0; } memset(b,0,sizeof b); for(int i=l1+1;i<=n;i++) { b[a[i]]=1; } for(int i=1;i<=l2;i++) { if(b[i]==0) return 0; } return 1;}bool jg2(){ memset(b,0,sizeof b); for(int i=1;i<=l2;i++) { b[a[i]]=1; } for(int i=1;i<=l2;i++) { if(b[i]==0) return 0; } memset(b,0,sizeof b); for(int i=l2+1;i<=n;i++) { b[a[i]]=1; } for(int i=1;i<=l1;i++) { if(b[i]==0) return 0; } return 1;}int main(){ ios::sync_with_stdio(false); int t; cin>>t; while(t--) { cin>>n; memset(a,0,sizeof a); mx=0; for(int i=1;i<=n;i++) { cin>>a[i]; mx=max(mx,a[i]); } l1=mx,l2=n-mx; bool f1=jg1(),f2=jg2(); if(l1<=0||l2<=0) { cout<<"0\n"; } else if(f1&&f2) { if(mx*2!=n) { cout<<"2\n"; cout<
<<" "<
<<"\n"; cout<
<<" "<
<<"\n"; } else { cout<<"1\n"; cout<
<<" "<
<<"\n"; } } else if(f1&&f2==0) { cout<<"1\n"; cout<
<<" "<
<<"\n";// cout<
<<" "<
<<"\n"; } else if(f1==0&&f2) { cout<<"1\n";// cout<
<<" "<
<<"\n"; cout<
<<" "<
<<"\n"; } else { cout<<"0\n"; } }}

转载地址:http://evrq.baihongyu.com/

你可能感兴趣的文章
mysql中数据表的基本操作很难嘛,由这个实验来带你从头走一遍
查看>>
Mysql中文乱码问题完美解决方案
查看>>
mysql中的 +号 和 CONCAT(str1,str2,...)
查看>>
Mysql中的 IFNULL 函数的详解
查看>>
mysql中的collate关键字是什么意思?
查看>>
MySql中的concat()相关函数
查看>>
mysql中的concat函数,concat_ws函数,concat_group函数之间的区别
查看>>
MySQL中的count函数
查看>>
MySQL中的DB、DBMS、SQL
查看>>
MySQL中的DECIMAL类型:MYSQL_TYPE_DECIMAL与MYSQL_TYPE_NEWDECIMAL详解
查看>>
MySQL中的GROUP_CONCAT()函数详解与实战应用
查看>>
MySQL中的IO问题分析与优化
查看>>
MySQL中的ON DUPLICATE KEY UPDATE详解与应用
查看>>
mysql中的rbs,SharePoint RBS:即使启用了RBS,内容数据库也在不断增长
查看>>
mysql中的undo log、redo log 、binlog大致概要
查看>>
Mysql中的using
查看>>
MySQL中的关键字深入比较:UNION vs UNION ALL
查看>>
mysql中的四大运算符种类汇总20多项,用了三天三夜来整理的,还不赶快收藏
查看>>
mysql中的字段如何选择合适的数据类型呢?
查看>>
MySQL中的字符集陷阱:为何避免使用UTF-8
查看>>