QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775893#8058. Binary vs TernaryNew_Folder#WA 1ms5636kbC++201.6kb2024-11-23 16:59:482024-11-23 16:59:48

Judging History

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

  • [2024-11-23 16:59:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5636kb
  • [2024-11-23 16:59:48]
  • 提交

answer

#pragma GCC optimize(2)
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[20001],b[20001];
int cnt=0;
int ans1[2000001];
int ans2[2000001];
void addans(int aa,int bb){
	ans1[++cnt]=aa;
	ans2[cnt]=bb;
}
void solve(){
	string s1,s2;
	cin>>s1>>s2;
	int l1=s1.length();
	int l2 = s2.length();
	vector<int> vec1(70),vec2(70);
	for(int i=1;i<=l1;i++){
		a[i]=s1[i-1]-'0';
	}
	for(int i=1;i<=l2;i++){
		b[i]=s2[i-1]-'0';
	}
	if(a[1]==1&&b[1]==1&&l1==1&&l2==1){
		cout<<0<<endl;
		return;
	}
	if(l1==1){
		cout<<-1<<endl;
		return;
	}
	for(int i=1;i<=l1-1;i++){
		if(a[i+1]==0){
			addans(i,i+1);
			a[i+1]=1;
		}
	}
	int now=l1;
	while(now>2){
		addans(1,2);
		addans(3,4);
		addans(2,3);
		now--;
	}
	int sec=-1;
	for(int i=2;i<=l2;i++){
		if(b[i]==1){
			sec=i;
			break;
		}
	}
	if(sec==-1){
		if(l2==2){
			addans(1,2);
			addans(2,3);
		}else{
			for(int i=4;i<=l2;i++){
				addans(1,2);
				addans(1,2);
			}
			addans(1,2);		
		}
	}else{
		for(int i=l2;i>sec;i--){
			if(b[i]==1){
				addans(1,2);
				addans(1,2);
				addans(2,3);
			}else{
				addans(1,2);
				addans(1,2);
			}
		}
		if(sec==3){
			addans(1,2);
			addans(1,3);
			addans(3,4);
		}else{
			if(sec>=5){
				addans(1,2);
				addans(1,3);
				addans(1,2);
			}
			for(int i=1;i<=sec-5;i++){
				addans(1,2);
				addans(1,2);
			}
			addans(1,2);
		}
	}
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++){
		cout<<ans1[i]<<' '<<ans2[i]<<endl;
	}
	cnt=0;
}

int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;cin>>T;while(T--)
	solve();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5636kb

input:

3
1
111
110110
1101010
1111
111111

output:

-1
27
2 3
5 6
1 2
3 4
2 3
1 2
3 4
2 3
1 2
3 4
2 3
1 2
3 4
2 3
1 2
1 2
1 2
1 2
2 3
1 2
1 2
1 2
1 2
2 3
1 2
1 2
1 2
19
1 2
3 4
2 3
1 2
3 4
2 3
1 2
1 2
2 3
1 2
1 2
2 3
1 2
1 2
2 3
1 2
1 2
2 3
1 2

result:

wrong answer S!=T after all operations (test case 2)