cf B. Jeff and Periods
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的更多相关文章
- B. Jeff and Periods(cf)
B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 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 ...
- Codeforces 352B - Jeff and Periods
352B - Jeff and Periods 思路:水题,考验实现(implementation)能力,来一波vector[允悲]. 代码: #include<bits/stdc++.h> ...
- CF352B Jeff and Periods 模拟
One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decide ...
- codeforces B. Jeff and Periods 解题报告
题目链接:http://codeforces.com/problemset/problem/352/B 题目意思:给出一个长度为n的序列 a1, a2, ..., an(序号i,1 <= i ...
- code forces Jeff and Periods
/* * c.cpp * * Created on: 2013-10-7 * Author: wangzhu */ #include<cstdio> #include<iostrea ...
- [CF 351B]Jeff and Furik[归并排序求逆序数]
题意: 两人游戏, J先走. 给出一个1~n的排列, J选择一对相邻数[题意!!~囧], 交换. F接着走, 扔一硬币, 若正面朝上, 随机选择一对降序排列的相邻数, 交换. 若反面朝上, 随机选择一 ...
- cf C. Jeff and Rounding
http://codeforces.com/contest/352/problem/C 题意:给予N*2个数字,改变其中的N个向上进位,N个向下进位,使最后得到得数与原来数的差的绝对值最小 对每一个浮 ...
- cf A. Jeff and Digits
http://codeforces.com/contest/352/problem/A #include <cstdio> #include <cstring> #includ ...
随机推荐
- sqlserver的rownum
oracle: select rownum from department sqlserver: select row_number() over (order by id) from dep ...
- CPU天梯图
一幅图,了解CPU
- Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)
题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...
- java中 SSL认证和keystore使用
java中 SSL认证和keystore使用 2013-10-12 11:08 10488人阅读 评论(0) 收藏 举报 目录(?)[+] 好久没用过SSL认证了,东西久不用,就有点生疏. ...
- Unity Inspector 给组件自动关联引用
项目进入上线阶段了, 有一些地方需要总结和优化. 我发现UI一改变,我就要拖很久的UI. UI结构发生改变我还必须给一些变量设置好引用,后来我去看别人预设的时候组件拖放的变量至少10个以上, 它们一 ...
- prototype对象的真正作用
参考阮一峰的文章:http://javascript.ruanyifeng.com/oop/encapsulation.html prototype对象的真正作用 在JavaScript语言中,每一个 ...
- 程序员实用的 MySQL sql 语句
这儿只讲究实用, 程序员编程时常用到的 MySQL的 sql语句(不包括基本的 select, update, delete 等语句). 1. 添加一个用户build,并赋予所有权限的命令 gran ...
- Android实现图片放大缩小
package com.min.Test_Gallery; import android.app.Activity; import android.graphics.Bitmap; import an ...
- jQuery之简单动画效果
1. show()显示动画 语法:show(speed,callback) Number/String,Function speend为动画执行时间,单位为毫秒.也可以为slow",&quo ...
- CentOS7--64安装python的psutil模块
1.以root身份登陆CentOS依次 执行以下命令: wget https://pypi.python.org/packages/source/p/psutil/psutil-2.1.3.tar.g ...