QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#462204#8058. Binary vs TernarymasterhuangWA 0ms3612kbC++17944b2024-07-03 15:35:422024-07-03 15:35:42

Judging History

你现在查看的是最新测评结果

  • [2024-07-03 15:35:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-07-03 15:35:42]
  • 提交

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;
}

详细

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)