diff --git a/NFLSOJ/13356/13356.cpp b/NFLSOJ/13356/13356.cpp new file mode 100644 index 00000000..a13f634b --- /dev/null +++ b/NFLSOJ/13356/13356.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include + +// 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> 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; +} diff --git a/NFLSOJ/13356/samples/chk.cpp b/NFLSOJ/13356/samples/chk.cpp new file mode 100644 index 00000000..833df6f0 --- /dev/null +++ b/NFLSOJ/13356/samples/chk.cpp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:927bdf6e2ddc3bca2c5ef12e7e17ba27f4a7d7fade9676b8bb2e6e15191c0578 +size 886 diff --git a/NFLSOJ/13356/samples/ex_rev1.ans b/NFLSOJ/13356/samples/ex_rev1.ans new file mode 100644 index 00000000..25bcdabc --- /dev/null +++ b/NFLSOJ/13356/samples/ex_rev1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41a3bca251cdfa049a930a7cbcd2ea5271e7e8bba96abb80a31aa9aca26dfdfb +size 13 diff --git a/NFLSOJ/13356/samples/ex_rev1.in b/NFLSOJ/13356/samples/ex_rev1.in new file mode 100644 index 00000000..0247d5e9 --- /dev/null +++ b/NFLSOJ/13356/samples/ex_rev1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d87a3d34a1b82f0c456882ef4719afc8c3c021fe5e2c73c823c4b38f82efd28c +size 22 diff --git a/NFLSOJ/13356/samples/ex_rev2.ans b/NFLSOJ/13356/samples/ex_rev2.ans new file mode 100644 index 00000000..ff83d47c --- /dev/null +++ b/NFLSOJ/13356/samples/ex_rev2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f1e37b4ecc384b4939c4a21fcf06548708ebd635a8494ab181b18625332a6e5 +size 4 diff --git a/NFLSOJ/13356/samples/ex_rev2.in b/NFLSOJ/13356/samples/ex_rev2.in new file mode 100644 index 00000000..3ba9c6a9 --- /dev/null +++ b/NFLSOJ/13356/samples/ex_rev2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a92364b46911bd4704ecf594c6affb395fab176845f562999409a2325f9742f3 +size 10