-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path352B Jeff and Periods.cpp
54 lines (53 loc) · 1.15 KB
/
352B Jeff and Periods.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
author : MishkatIT
created : Tuesday 2023-06-06-01.56.07
*/
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(_) cout << #_ << " is " << _ << '\n';
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll N = 1e5 + 10;
const ll inf = 1e9;
const ll linf = 1e18;
int main()
{
fio;
int n;
cin >> n;
vector<int> v[N];
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
v[x]. push_back(i);
}
vector<pair<int, int>> ans;
for (int i = 1; i < N; i++)
{
if(v[i].size() == 1)
{
ans.push_back({i, 0});
}
else if(v[i].size() > 1)
{
int dif = v[i][1] - v[i][0];
bool same = true;
for (int j = 0; j + 1 < v[i].size(); j++)
{
same &= ((v[i][j + 1] - v[i][j]) == dif);
}
if(same)
{
ans.push_back({i, dif});
}
}
}
cout << ans.size() << '\n';
for(auto& i: ans)
{
cout << i.first << ' ' << i.second << '\n';
}
return 0;
}