Codeforces 352B - Jeff and Periods
思路:水题,考验实现(implementation)能力,来一波vector[允悲]。
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset((a),(b),sizeof(a))
const int N=1e5+;
vector<int>g[N];
vector<int>ans;
bool vis[N]={false}; int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,a;
cin>>n;
for(int i=;i<=n;i++)
{
cin>>a;
if(vis[a])continue;
if(!g[a].size()||g[a].size()==)g[a].pb(i);
else
{
if(i-g[a][g[a].size()-]!=g[a][g[a].size()-]-g[a][g[a].size()-])vis[a]=true,g[a].clear();
else g[a].pb(i);
}
} int cnt=;
for(int i=;i<N;i++)
{
if(g[i].size())
{
cnt++;
ans.pb(i);
}
}
cout<<cnt<<endl;
for(int i=;i<ans.size();i++)
{
cout<<ans[i];
if(g[ans[i]].size()==)cout<<' '<<<<endl;
else cout<<' '<<g[ans[i]][g[ans[i]].size()-]-g[ans[i]][g[ans[i]].size()-]<<endl;
}
return ;
}
Codeforces 352B - Jeff and Periods的更多相关文章
- codeforces B. Jeff and Periods 解题报告
题目链接:http://codeforces.com/problemset/problem/352/B 题目意思:给出一个长度为n的序列 a1, a2, ..., an(序号i,1 <= i ...
- 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 ...
- B. Jeff and Periods(cf)
B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces 351D Jeff and Removing Periods(莫队+区间等差数列更新)
题目链接:http://codeforces.com/problemset/problem/351/D 题目大意:有n个数,每次可以删除掉数值相同并且所在位置成等差数列的数(只删2个数或者只删1个数应 ...
- Codeforces 351B Jeff and Furik:概率 + 逆序对【结论题 or dp】
题目链接:http://codeforces.com/problemset/problem/351/B 题意: 给你一个1到n的排列a[i]. Jeff和Furik轮流操作,Jeff先手. Jeff每 ...
- codeforces A. Jeff and Digits 解题报告
题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这 ...
- CodeForces 352C. Jeff and Rounding(贪心)
C. Jeff and Rounding time limit per test: 1 second memory limit per test: 256 megabytes input: stan ...
- codeforces A. Jeff and Rounding (数学公式+贪心)
题目链接:http://codeforces.com/contest/351/problem/A 算法思路:2n个整数,一半向上取整,一半向下.我们设2n个整数的小数部分和为sum. ans = |A ...
- cf B. Jeff and Periods
http://codeforces.com/contest/352/problem/B #include <cstdio> #include <cstring> #includ ...
随机推荐
- Lifyray笑傲江湖之API总结TextUtil
package liferay; /** * */ import java.text.DecimalFormat; import java.text.NumberFormat; import java ...
- VS2010/MFC编程入门之四十五(MFC常用类:CFile文件操作类)
上一节中鸡啄米讲了定时器Timer的用法,本节介绍下文件操作类CFile类的使用. CFile类概述 如果你学过C语言,应该知道文件操作使用的是文件指针,通过文件指针实现对它指向的文件的各种操作.这些 ...
- 数据仓库基础(八)Informatica 小例子
本文转载自:http://www.cnblogs.com/evencao/p/3147843.html 之前看了一段数据库的基础,感觉自己对数据库的基础挺薄弱的.以后再学习其他东西的时候也需要经常能学 ...
- python webdriver 测试框架-行为驱动例子
安装行为驱动模块lettuce(卷心菜)模块 pip install lettuce Successfully installed argparse-1.4.0 colorama-0.3.9 extr ...
- python webdriver 登陆163邮箱给QQ邮箱发送一个邮件,显示等待
#encoding=utf-8 import unittest import time from selenium import webdriver from selenium.webdriver i ...
- spring mvc @ModelAttribute 每次执行requestmapping前自动执行
在不少应用场景中,我们希望在每次执行requestmapping前自动执行一些操作,比如把某些数据(比如数据字典.系统配置.标准错误号,这在企业应用系统中极为常见)塞到model中供view访问,因为 ...
- 利用脚本kill掉进程, 语法:运行脚本+进程名
下面附上脚本, 权限需要附X执行 #!/bin/sh #pid kill thread for chenglee #if fileformat=dos, update fileformat=unix ...
- Python3基础 str 循环输出list中每个单词及其长度
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 入门dp总结
写这篇博文主要是为了归纳总结一下dp的有关问题(不定期更新,暑假应该会更的快一些) 会大概讲一下思路,不会事无巨细地讲 另一篇是平时做过的一些dp题,这篇博客里面提到的题都有题解放在那边:https: ...
- Java Session 会话技术
什么是Java Session? 大图:http://images2017.cnblogs.com/blog/1030087/201712/1030087-20171223235950881-1310 ...