QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#727127 | #8058. Binary vs Ternary | woaimtw# | WA | 1ms | 3564kb | C++23 | 1.7kb | 2024-11-09 11:36:29 | 2024-11-09 11:36:32 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<unordered_map>
#include<stack>
using namespace std;
#define int long long
#define scanf scanf_s
typedef pair<int, int> PII;
const double ef = 1e-12;
const int INF = 0x3f3f3f3f3f3f3f3f;
#define rep(i,a, b) for(int i = a;i<=b;i++)
#define pre(i,a, b) for(int i = a;i>=b;i--)
const int N = 5e5 + 5;
string a, b;
int cnt;
int ans[600][2];
int n, m;
void cun(int x, int y)
{
ans[++cnt][0] = x;
ans[cnt][1] = y;
}
void init()
{
rep(i, 1, n) {
if (a[i] == '0') cun(i - 1, i);
}
pre(i, n, 2) cun(i - 1, i);
cun(2, 2 * n - 1);
}
void solve()
{
cin >> a;
cin >> b;
n = a.size();
m = b.size();
a = " " + a;
b = " " + b;
cnt = 0;
if (n == 1)
{
if (a == b) {
cout << 0 << endl;
}
else cout << -1 << endl;
return;
}
if (m == 1)
{
cout << -1 << endl;
return;
}
init();
rep(i, 3, m) {
cun(1, 2);
cun(1, 2);
}
rep(i, 2, m) cun(i - 1, i);
rep(i, 2, m)
{
if (b[i] == '0')
{
cun(i - 1, i);
cun(i, i + 1);
}
}
if (cnt >= 512) while (1);
cout << cnt << endl;
rep(i, 1, cnt) {
cout << ans[i][0] << " " << ans[i][1] << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3560kb
input:
3 1 111 110110 1101010 1111 111111
output:
-1 30 2 3 5 6 5 6 4 5 3 4 2 3 1 2 2 11 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 3 3 4 4 5 5 6 6 7 2 3 3 4 4 5 5 6 6 7 7 8 17 3 4 2 3 1 2 2 7 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 3 3 4 4 5 5 6
result:
ok Haitang Suki (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3564kb
input:
1000 11100 111 1 11110 10001 10 1011 1111 10 1110 1100 11 11010 11 110 11 1 10001 10110 10 10 11111 10000 1001 10 1 11 10111 11 10 1 100 11 10100 1 10 101 11 1100 110 11 1110 1 1001 1 11111 10 10010 10 11001 110 1010 10011 1110 10100 1001 1001 101 100 1 1001 11 101 11 101 1001 1 1 1011 1 10 10 1011 ...
output:
11 3 4 4 5 4 5 3 4 2 3 1 2 2 9 1 2 1 2 1 2 2 3 -1 11 1 2 2 3 3 4 4 5 3 4 2 3 1 2 2 9 1 2 1 2 2 3 12 1 2 3 4 2 3 1 2 2 7 1 2 1 2 1 2 1 2 1 2 2 3 3 4 12 1 2 1 2 2 3 1 2 1 2 1 2 1 2 1 2 2 3 3 4 3 4 4 5 7 2 3 3 4 3 4 2 3 1 2 2 7 1 2 8 2 3 4 5 4 5 3 4 2 3 1 2 2 9 1 2 5 2 3 2 3 1 2 2 5 1 2 -1 10 1 2 4 5 4...
result:
wrong answer (l,r) is invalid (test case 12)