QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#462204 | #8058. Binary vs Ternary | masterhuang | WA | 0ms | 3612kb | C++17 | 944b | 2024-07-03 15:35:42 | 2024-07-03 15:35:42 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define P pair<int,int>
#define fi first
#define se second
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=105;
int T,n,m,a[N],b[N];
string A,B;vector<P>ans;
inline void add(int l,int r){ans.push_back({l,r});}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>T;
while(T--)
{
cin>>A>>B;
if(A==B){cout<<"0\n";continue;}
if(A=="1"||B=="1"){cout<<"-1\n";continue;}
n=A.size(),m=B.size();ans.clear();
for(int i=1;i<=n;i++) a[i]=A[i-1]-'0';
for(int i=1;i<=m;i++) b[i]=B[i-1]-'0';
for(int i=1;i<=n;i++) if(!a[i]) add(i-1,i);
if(n<m) for(int i=n+1;i<=m;i++) add(i-2,i-1),add(i-2,i-1),add(i-1,i);
if(n>m) for(int i=n;i>m;i--) add(i-1,i),add(i,i);
for(int i=m;i;i--) if(!b[i]) add(i-1,i),add(i+1,i+1);
cout<<ans.size()<<"\n";for(auto [l,r]:ans) cout<<l<<" "<<r<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3612kb
input:
3 1 111 110110 1101010 1111 111111
output:
-1 11 2 3 5 6 5 6 5 6 6 7 6 7 8 8 4 5 6 6 2 3 4 4 6 3 4 3 4 4 5 4 5 4 5 5 6
result:
wrong answer S!=T after all operations (test case 2)