QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#616703 | #8058. Binary vs Ternary | LuoYilun | WA | 3ms | 3712kb | C++17 | 1.8kb | 2024-10-06 10:25:26 | 2024-10-06 10:25:26 |
Judging History
answer
//#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <stack>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <random>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) (x&-x)
#define ls k<<1
#define rs (k<<1)|1
#define mid ((l+r)>>1)
#define all(x) s.begin(),x.end()
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define LYLNB ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef unsigned long long u64;
//#define int long long
string s, t;
vector<pii>ans;
void w(int l, int r) { ans.push_back({ l,r }); }
void solve() {
cin >> s >> t;
int n = s.length(), m = t.length();
if (n == 1 || m == 1) {
if (n == 1 && m == 1 && s[0] == t[0]) {
cout << 0 << endl;
}
else cout << -1 << endl;
return;
}
for (int i = 2; i <= n; i++) {
if (s[i - 1] == '0') {
w(i - 1, i);
}
}
if (n > m) {
for (int i = 1; i <= n - m; i++) {
w(1, 2); w(2, 3); w(1, 2);
}
}
else{
for (int i = 1; i <= m - n; i++) {
w(1, 2); w(1, 2); w(2, 3);
}
}
for (int i = 2; i <= m; i++) {
if (t[i - 1] == '0') {
w(i - 1, i); w(i, i + 1);
}
}
cout << ans.size() << endl;
for (pii p : ans)cout << p.first << " " << p.second << endl;
ans.clear();
}
signed main() {
LYLNB;
int T = 1; cin >> T;
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
3 1 111 110110 1101010 1111 111111
output:
-1 11 2 3 5 6 1 2 1 2 2 3 2 3 3 4 4 5 5 6 6 7 7 8 6 1 2 1 2 2 3 1 2 1 2 2 3
result:
ok Haitang Suki (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3648kb
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:
8 3 4 4 5 1 2 2 3 1 2 1 2 2 3 1 2 -1 14 1 2 2 3 3 4 1 2 2 3 1 2 1 2 2 3 1 2 1 2 2 3 1 2 1 2 2 3 1 1 2 9 1 2 1 2 1 2 2 3 1 2 1 2 2 3 3 4 4 5 8 2 3 3 4 1 2 2 3 1 2 1 2 2 3 1 2 11 2 3 4 5 1 2 2 3 1 2 1 2 2 3 1 2 1 2 2 3 1 2 4 2 3 1 2 2 3 1 2 -1 13 1 2 4 5 1 2 2 3 1 2 1 2 2 3 1 2 1 2 2 3 1 2 1 2 2 3 10 ...
result:
wrong answer S!=T after all operations (test case 1)