-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc2206.cc
68 lines (62 loc) · 873 Bytes
/
aoc2206.cc
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "iostream"
#include "vector"
using namespace std;
int main()
{
vector<string> a;
string s;
int n, i, j;
int r1, r2;
while (cin >> s)
a.push_back(s);
bool ok = false;
int p2 = 14;
for (string& l : a)
{
i = -1;
n = (int) l.length();
while (++i < n - 4)
{
s = l.substr(i, 4);
sort(s.begin(), s.end());
j = 0;
ok = false;
while (++j < 4 && !ok)
{
if (s[j - 1] == s[j])
{
ok = true;
break ;
}
}
if (!ok)
{
r1 = i + 4;
break;
}
}
i = -1;
while (++i < n - p2)
{
s = l.substr(i, p2);
sort(s.begin(), s.end());
j = 0;
ok = false;
while (++j < p2 && !ok)
{
if (s[j - 1] == s[j])
{
ok = true;
break ;
}
}
if (!ok)
{
r2 = i + p2;
break;
}
}
}
cout << "Star 1: " << r1 << endl;
cout << "Star 2: " << r2 << endl;
}