forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathK.cpp
More file actions
35 lines (30 loc) · 681 Bytes
/
K.cpp
File metadata and controls
35 lines (30 loc) · 681 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
34
35
#include <bits/stdc++.h>
using namespace std;
char a[10100], b[10100];
int main()
{
scanf("%s%s", a, b);
int n = strlen(a);
vector < pair<int,int> > ans;
for (int i = 0; i < n; i++)
if (a[i] != b[i])
{
int sum = 0, j;
for (j = i; j < n; j++)
{
sum += a[j] - '0';
if (a[j] == b[i] && sum % 2 == 0)
break;
}
if (j == n)
{
cout << "NO" << endl;
return 0;
}
ans.push_back({i, j});
reverse(a + i, a + j + 1);
}
cout << "YES" << endl << ans.size() << endl;
for (auto u : ans)
printf("%d %d\n", u.first + 1, u.second + 1);
}