0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:05:26 +00:00

#13356. 「NOIP2022模拟赛1119」rev

http://www.nfls.com.cn:10611/submission/242774
This commit is contained in:
Baoshuo Ren 2022-11-20 08:52:22 +08:00
parent 7de31ae74a
commit 777fd68b87
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
6 changed files with 78 additions and 0 deletions

63
NFLSOJ/13356/13356.cpp Normal file
View File

@ -0,0 +1,63 @@
#include <iostream>
#include <algorithm>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
// using std::cin;
// using std::cout;
std::ifstream cin("rev.in");
std::ofstream cout("rev.out");
const char endl = '\n';
std::string s, t;
std::vector<std::pair<int, int>> ans;
bool check() {
if (std::count(s.begin(), s.end(), '1') != std::count(t.begin(), t.end(), '1')) {
return false;
}
for (int i = 0; i < s.size(); i++) {
if (s[i] == t[i]) continue;
int cnt = 0;
bool flag = false;
for (int j = i; j < s.size(); j++) {
if (s[j] == '1') cnt++;
if (s[j] == t[i] && cnt % 2 == 0) {
flag = true;
ans.emplace_back(i + 1, j + 1);
std::reverse(s.begin() + i, s.begin() + j + 1);
break;
}
}
if (!flag) return false;
}
return true;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> s >> t;
if (check()) {
cout << "YES" << endl
<< ans.size() << endl;
for (auto e : ans) {
cout << e.first << ' ' << e.second << endl;
}
} else {
cout << "NO" << endl;
}
return 0;
}

BIN
NFLSOJ/13356/samples/chk.cpp (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13356/samples/ex_rev1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13356/samples/ex_rev1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13356/samples/ex_rev2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NFLSOJ/13356/samples/ex_rev2.in (Stored with Git LFS) Normal file

Binary file not shown.