forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
33 lines (31 loc) · 833 Bytes
/
B.cpp
File metadata and controls
33 lines (31 loc) · 833 Bytes
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
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
int main() {
string str;
cin >> str;
vector<vector<int> > mm(26, vector<int>());
REP(i,str.length()) mm[str[i] - 'A'].push_back(i);
int res = 1;
REP(i,26) {
if (mm[i].empty()) continue;
REP(j,mm[i].size()) {
int st = mm[i][j];
int n = 1;
FOR(k,j+1,mm[i].size()-1) {
int d = mm[i][k] - st;
if (d & 1) {
++n;
st = mm[i][k];
}
}
res = max(res, n);
}
}
cout << res << endl;
return 0;
}