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

cf B. Jeff and Periods的更多相关文章

  1. B. Jeff and Periods(cf)

    B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #204 (Div. 2)->B. Jeff and Periods

    B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces 352B - Jeff and Periods

    352B - Jeff and Periods 思路:水题,考验实现(implementation)能力,来一波vector[允悲]. 代码: #include<bits/stdc++.h> ...

  4. CF352B Jeff and Periods 模拟

    One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decide ...

  5. codeforces B. Jeff and Periods 解题报告

    题目链接:http://codeforces.com/problemset/problem/352/B 题目意思:给出一个长度为n的序列   a1, a2, ..., an(序号i,1 <= i ...

  6. code forces Jeff and Periods

    /* * c.cpp * * Created on: 2013-10-7 * Author: wangzhu */ #include<cstdio> #include<iostrea ...

  7. [CF 351B]Jeff and Furik[归并排序求逆序数]

    题意: 两人游戏, J先走. 给出一个1~n的排列, J选择一对相邻数[题意!!~囧], 交换. F接着走, 扔一硬币, 若正面朝上, 随机选择一对降序排列的相邻数, 交换. 若反面朝上, 随机选择一 ...

  8. cf C. Jeff and Rounding

    http://codeforces.com/contest/352/problem/C 题意:给予N*2个数字,改变其中的N个向上进位,N个向下进位,使最后得到得数与原来数的差的绝对值最小 对每一个浮 ...

  9. cf A. Jeff and Digits

    http://codeforces.com/contest/352/problem/A #include <cstdio> #include <cstring> #includ ...

随机推荐

  1. IBM Cognos 10 启动报错

    报错信息: 15:35:02, 'LogService', 'StartService', 'Success'. 15:35:03, CAF input validation enabled. 15: ...

  2. rsyslog 读取单个文件测试

    rsyslog 测试(rsyslog 必须yum 安装uat-web02:/root# rpm -qa | grep rsyslog rsyslog-8.21.0-1.el6.x86_64) //读取 ...

  3. 【转】Everything中文绿色版在Win7/8用不了?

    原文网址:http://pcedu.pconline.com.cn/472/4727542.html 用过Everything的朋友应该都知道,Everything有两个版本,一个是安装版,另一个是E ...

  4. 各种计算机语言的经典书籍(C/C++/Java/C#/VC/VB等)

    1.Java Java编程语言(第三版)-Java四大名著--James Gosling(Java之父) Java编程思想(第2版)--Java四大名著--Bruce Eckel Java编程思想(第 ...

  5. cocos2d-x 几何绘制: DrawingPrimitives 和 CCDrawNode

    在看书的时候只提到了DrawingPrimitives,然后我去搜索这个类,结果没搜到.心想难道是类名改了,那我搜方法名吧,搜了下DrawLine,果然被我搜到了.结果发现原来这些各方法都是全局函数, ...

  6. HDU-1047(DP-二进制状态压缩)

    Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of h ...

  7. velocity自定义动画

         话说好久没有写博客了,零星的整理了一些东西,没有形成系统,所以也没有在这里记录.        废话不多说了,进入今天的正题.不知道大家是否记得之前写过的一篇文章<制作炫酷的专题页面& ...

  8. Java正則表達式语法

    Java正則表達式语法 字符 说明 \ 将下一字符标记为特殊字符.文本.反向引用或八进制转义符.比如,"n"匹配字符"n"."\n"匹配换行 ...

  9. android音乐播放器开发 SweetMusicPlayer 实现思路

    一,实现效果 眼下还不是特别完好,主要有下面几个功能, 1,载入歌曲列表(实现a-z字母检索) 2,播放本地音乐 3.智能匹配本地歌词 4.智能载入在线歌词(事实上不算智能.发现歌词迷api提供的歌词 ...

  10. MODULE_DEVICE_TABLE

    1. MODULE_DEVICE_TABLE (usb, skel_table);该宏生成一个名为__mod_pci_device_table的局部变量,该变量指向第二个参数.内核构建时,depmod ...