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

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. using namespace std;
  5. int a[];
  6. int n;
  7. bool vis[];
  8. int len;
  9. struct node
  10. {
  11. int x,id;
  12. bool operator <(const node &a)const
  13. {
  14. return (x<a.x)||(x==a.x&&id<a.id);
  15. }
  16. } p[],p1[];
  17. int main()
  18. {
  19. while(scanf("%d",&n)!=EOF)
  20. {
  21. memset(vis,,sizeof(vis));
  22. int cnt=;
  23. for(int i=; i<=n; i++)
  24. {
  25. scanf("%d",&a[i]);
  26. p[cnt].x=a[i];
  27. p[cnt++].id=i;
  28. }
  29. sort(p,p+cnt);
  30. bool flag1=false;
  31. int cnt1=;
  32. bool flag2=false;
  33. bool flag3=false;
  34. for(int i=; i<cnt; i++)
  35. {
  36. if(!vis[p[i].x])
  37. {
  38. if(!flag1)
  39. {
  40. flag1=true;
  41. }
  42. else
  43. {
  44. if(!flag2)
  45. {
  46. p1[cnt1].x=p[i-].x;
  47. p1[cnt1++].id=len;
  48. }
  49. }
  50. flag2=false;
  51. flag3=false;
  52. len=;
  53. vis[p[i].x]=true;
  54. }
  55. else
  56. {
  57. if(flag2)continue;
  58. if(!flag3)
  59. {
  60. len=p[i].id-p[i-].id;
  61. flag3=true;
  62. }
  63. else
  64. {
  65. if(p[i].id-p[i-].id!=len)
  66. {
  67. flag2=true;
  68. }
  69. }
  70. }
  71. }
  72. if(!flag2)
  73. {
  74. p1[cnt1].x=p[cnt-].x;
  75. p1[cnt1++].id=len;
  76. }
  77. printf("%d\n",cnt1);
  78. for(int i=; i<cnt1; i++)
  79. {
  80. printf("%d %d\n",p1[i].x,p1[i].id);
  81. }
  82. }
  83. return ;
  84. }

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. 一个坑:java.sql.ResultSet.getInt==》the column value; if the value is SQL NULL, the value returned is 0

    Retrieves the value of the designated column in the current row of this ResultSet object as a String ...

  2. BZOJ3402: [Usaco2009 Open]Hide and Seek 捉迷藏

    3402: [Usaco2009 Open]Hide and Seek 捉迷藏 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 51  Solved: 4 ...

  3. 关于我的FGC的OAuth2.0认证。

    这个名字估计很冷门,估计不会有人看到吧,我猜测的. (阅读以下全文之前请先搞定翻^#$%@#墙这件事.昨天看了一个笑话说墙之父方校长说自己有六个VPN账号,只是为了测试自己的墙好用还是VPN好用.哈哈 ...

  4. codevs1033 蚯蚓的游戏问题

    题目描述 Description 在一块梯形田地上,一群蚯蚓在做收集食物游戏.蚯蚓们把梯形田地上的食物堆积整理如下: a(1,1)  a(1,2)…a(1,m) a(2,1)  a(2,2)  a(2 ...

  5. 使用MapReduce将HDFS数据导入到HBase(二)

    package com.bank.service; import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.conf. ...

  6. RHEL修改主机名和IP

    1,     修改主机名 vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=NEWHOSTNAME       #修改该值作为主机名,如:NEWPC ...

  7. 四、Solr数据源配置(JNDI、DIH)及定时重做索引

    简介 Solr支持很多种创建索引的方式,包括网页,xml以及数据库,因为我这边做的是企业级的搜索,所以用的是数据库建立索引.其实从数据库建立索引,很大程度上取决于原来的数据库设计. 从数据库建立索引, ...

  8. android怎样写一个循环文字滚动的TextView

    效果图: 在layout中这样来声明: <com.kaixin001.view.ScrollText android:id="@+id/news_statustxt" and ...

  9. Mysql数据库里面的String类型依照数字来排序以及按时间排序的sql语句

    今天做项目的时候,遇到个小小的问题,在数据库中查询的时候,要用String类型的ID进行一下排序!(注:ID字段为 varchar 类型) 解决的方法: 如: SELECT * FROM  Stude ...

  10. 关于js中 document.body.scrollTop 不能返回正确值的原因

    本来是为了通过document.body.scrollTop来获取浏览器垂直滚动条向下滚动的像素,但是不管滚动条在什么位置总是返回是0,造成这样的原因和html的头部声明有关,如果头部声明 为:< ...