QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#654397 | #8058. Binary vs Ternary | zqx# | WA | 0ms | 3544kb | C++23 | 1.8kb | 2024-10-18 21:30:58 | 2024-10-18 21:31:14 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pii pair < int , int >
using namespace std;
const int N = 64 + 10;
void Solve()
{
vector < int > a, b;
string s, t;
int n, m;
cin >> s >> t;
vector < pii > ans;
for (auto si : s)
a.push_back(si - '0');
for (auto ti : t)
b.push_back(ti - '0');
//tp
// 00 -> 0
n = (int)a.size() - 1, m = (int)b.size() - 1;
for (int i = 0; i < n; i++)
{
if (a[i] == 0 && a[i + 1] == 0)
{
ans.push_back({i, i + 1});
a.erase(a.begin() + i);
}
}
if ((int)a.size() > (int)b.size() || ((int)a.size() == 1 && a != b))
{
cout << -1 << "\n";
return ;
}
// 10 -> 11
n = (int)a.size() - 1, m = (int)b.size() - 1;
for (int i = 0; i < n; i++)
{
if (a[i] == 1 && a[i + 1] == 0)
{
ans.push_back({i, i + 1});
a[i + 1] = 1;
}
}
// n -> m
int ct = (int)b.size() - (int)a.size();
for (int i = 1; i <= ct; i++)
{
n = (int)a.size() - 1;
ans.push_back({n - 1, n});
ans.push_back({n - 1, n});
ans.push_back({n, n + 1});
a.push_back(1);
}
n = (int)a.size() - 1;
for (int i = 0; i < n; i++)
{
if (b[i] == 0)
{
ans.push_back({i - 1, i});
ans.push_back({i, i + 1});
a[i] = 0;
}
}
cout << ans.size() << "\n";
for (auto [l, r] : ans)
cout << l + 1 << " " << r + 1 << "\n";
return ;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T = 1;
cin >> T;
while (T--)
{
Solve();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
input:
3 1 111 110110 1101010 1111 111111
output:
-1 9 2 3 5 6 5 6 5 6 6 7 2 3 3 4 4 5 5 6 6 3 4 3 4 4 5 4 5 4 5 5 6
result:
wrong answer S!=T after all operations (test case 2)