QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#376193 | #8058. Binary vs Ternary | Eunoiay | WA | 0ms | 3488kb | C++20 | 1.1kb | 2024-04-03 23:35:55 | 2024-04-03 23:35:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
string a, b;
cin >> a >> b;
if (a == "1" || b == "1") {
cout << (a == b ? 0 : -1) << "\n";
return;
}
int n = a.size();
int m = b.size();
vector<pair<int, int>> ans;
for (int i = 0; i + 1 < n; ++i) {
if (a[i] == '1' && a[i + 1] == '0') {
ans.emplace_back(i + 1, i + 2);
a[i + 1] = '1';
}
}
while (a.size() < b.size()) {
ans.emplace_back(n - 1, n);
ans.emplace_back(n - 1, n);
ans.emplace_back(n, n + 1);
a += '1';
++n;
}
while (a.size() > b.size()) {
ans.emplace_back(n - 2, n - 1);
ans.emplace_back(n - 1, n + 1);
a.pop_back();
--n;
}
for (int i = m - 1; i >= 0; --i) {
if (b[i] == '0') {
ans.emplace_back(n - 1 - i, n - i);
ans.emplace_back(n - i, n + 1 - i);
a[i] = '0';
}
}
cout << ans.size() << "\n";
for (auto [x, y] : ans) {
cout << x << " " << y << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3488kb
input:
3 1 111 110110 1101010 1111 111111
output:
-1 11 2 3 5 6 5 6 5 6 6 7 0 1 1 2 2 3 3 4 4 5 5 6 6 3 4 3 4 4 5 4 5 4 5 5 6
result:
wrong answer Integer parameter [name=l] equals to 0, violates the range [1, 128] (test case 2)