include iostream include vector include string using namespace std int

 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
int n, q = 0;
string s;
vector<pair<int, int> > a;
cin >> n >> s;
for (int i = 0; i < n; ++i)
{
if (s[i] == '*')
{
int p = 1;
while (s[i + p] == '*' && i + p < n)
p++;
pair<int, int> b;
b.first = i;
b.second = p;
a.push_back(b);
i += p - 1;
q += p;
}
}
if (q == 0)
{
cout << 0 << endl;
return 0;
}
pair<int, int> sh;
sh.first = a[0].first;
sh.second = a[0].second - 1;
int k = 0, r = 2;
for (int i = 1; i < a.size(); ++i)
{
if (sh.second - k < a[i].first - sh.first - sh.second - 1 /* ?? */)
{
r += sh.second - k + 1;
sh.second = a[i].second - 1;
sh.first = a[i].first;
k = 0;
}
else
{
k += a[i].first - sh.first - sh.second - 1;
sh.second = a[i].first + a[i].second - sh.first - 1;
}
}
r += k;
if (sh.second > 1)
{
cout << r << endl;
cout << sh.first + 1 << endl << "Shift+" << sh.first + sh.second + 1<< endl;
for (int i = 0; i < n; ++i)
{
if ((i < sh.first || i > sh.first + sh.second) && s[i] == '*')
cout << "Ctrl+" << i + 1 << endl;
if ((i > sh.first && i < sh.first + sh.second) && s[i] == '.')
cout << "Ctrl+" << i + 1 << endl;
}
}
else
{
cout << q << endl;
bool t = false;
for (int i = 0; i < n; ++i)
{
if (s[i] == '*')
if (t)
cout << "Ctrl+" << i + 1 << endl;
else
{
t = true;
cout << i + 1 << endl;
}
}
}
return 0;
}