QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#536407 | #8058. Binary vs Ternary | ucup-team3591# | WA | 0ms | 1628kb | C++14 | 1.4kb | 2024-08-29 11:08:05 | 2024-08-29 11:08:05 |
Judging History
answer
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline ll read(){
ll x=0;
int f=0,ch=0;
while(ch<48||ch>57) f=(ch=='-'),ch=getchar();
while(ch>47&&ch<58) x=(x<<3)+(x<<1)+(ch&15),ch=getchar();
return f?-x:x;
}
inline void write(ll x,char end='\n'){
if(x==0){
putchar('0');
putchar(end);
return;
}
if(x<0) putchar('-'),x=-x;
int ch[40]={0},cnt=0;
while(x){
ch[cnt++]=(int)(x%10);
x/=10;
}
while(cnt--) putchar(ch[cnt]+48);
putchar(end);
}
const int N=72;
#define mp make_pair
#define pii pair<int,int>
char a[N],b[N];
int ans;
pii plan[N<<3];
inline void solve(){
scanf("%s%s",a+1,b+1);
int n=strlen(a+1),m=strlen(b+1);
if(n==1||m==1){
if(n==m) puts("0");
else puts("-1");
return;
}
ans=0;
for(int i=1;i<n;++i){
if(a[i+1]=='0'){
a[i+1]='1';
plan[++ans]=mp(i,i+1);
}
}
while(n<m){
plan[++ans]=mp(1,2);
plan[++ans]=mp(1,3);
plan[++ans]=mp(1,2);
plan[++ans]=mp(2,3);
++n;
}
while(n>m){
plan[++ans]=mp(2,3);
plan[++ans]=mp(2,4);
plan[++ans]=mp(2,3);
plan[++ans]=mp(2,4);
plan[++ans]=mp(1,2);
}
for(int i=1;i<=n;++i) a[i]='1';
for(int i=1;i<n;++i){
if(b[i+1]=='0'){
plan[++ans]=mp(i,i+1);
plan[++ans]=mp(i+1,i+2);
}
}
write(ans,'\n');
for(int i=1;i<=ans;++i)
printf("%d %d\n",plan[i].first,plan[i].second);
}
int main(){
int T=read();
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1628kb
input:
3 1 111 110110 1101010 1111 111111
output:
-1 12 2 3 5 6 1 2 1 3 1 2 2 3 2 3 3 4 4 5 5 6 6 7 7 8 8 1 2 1 3 1 2 2 3 1 2 1 3 1 2 2 3
result:
wrong answer S!=T after all operations (test case 2)