http://codeforces.com/contest/352/problem/B

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[];
int n;
bool vis[];
int len;
struct node
{
int x,id;
bool operator <(const node &a)const
{
return (x<a.x)||(x==a.x&&id<a.id);
}
} p[],p1[];
int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(vis,,sizeof(vis));
int cnt=;
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
p[cnt].x=a[i];
p[cnt++].id=i;
}
sort(p,p+cnt);
bool flag1=false;
int cnt1=;
bool flag2=false;
bool flag3=false;
for(int i=; i<cnt; i++)
{
if(!vis[p[i].x])
{
if(!flag1)
{
flag1=true;
}
else
{
if(!flag2)
{
p1[cnt1].x=p[i-].x;
p1[cnt1++].id=len;
}
}
flag2=false;
flag3=false;
len=;
vis[p[i].x]=true;
}
else
{
if(flag2)continue;
if(!flag3)
{
len=p[i].id-p[i-].id;
flag3=true;
}
else
{
if(p[i].id-p[i-].id!=len)
{
flag2=true;
}
}
}
}
if(!flag2)
{
p1[cnt1].x=p[cnt-].x;
p1[cnt1++].id=len;
}
printf("%d\n",cnt1);
for(int i=; i<cnt1; i++)
{
printf("%d %d\n",p1[i].x,p1[i].id);
}
}
return ;
}

最新文章

  1. 在CentOS 7中安装nginx服务器
  2. Leetcode 290 Word Pattern STL
  3. 初学Node(六)搭建一个简单的服务器
  4. java帮助文档下载
  5. 获取url中的参数\+发送ajax请求根路径|+获取复选框的值
  6. bzoj 2324: [ZJOI2011]营救皮卡丘
  7. UVA 10246 Asterix and Obelix
  8. google map api 学习笔记
  9. Rocketmq整体分析
  10. Oracle 转换函数
  11. WHM API 1 - createacct
  12. JVM中GC浅解:垃圾回收的了解
  13. CSS3弹性伸缩布局(上)——box布局
  14. JavaEE开发之Spring中的依赖注入与AOP编程
  15. CMS Collector and G1 Collector
  16. prometheus的agent 二次开发代码参考
  17. (转)注解用法详解—@@SuppressWarnings
  18. hdu1716排列2(stl:next_permutation+优先队列)
  19. [JSOI2018]潜入行动
  20. Jenkins 集成 git .net 和nuget

热门文章

  1. makefile高级用法--使用函数
  2. HDU_1426——数独问题,DFS
  3. javaweb笔记2之HTTP协议
  4. svn版本信息自动更新到源代码
  5. JS-Date日期内置对象
  6. SQL Server 系统时间
  7. MySQL慢查询(一) - 开启慢查询
  8. 修改文件所有者 chown
  9. Eclipse 4.2 + Tomcat 7.x + JDK 7 搭建Java Web开发环境
  10. Word01-从正文处开始插入页码