QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775919#8058. Binary vs TernaryNew_Folder#WA 1ms5544kbC++201.7kb2024-11-23 17:03:282024-11-23 17:03:28

Judging History

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

  • [2024-11-23 17:03:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5544kb
  • [2024-11-23 17:03:28]
  • 提交

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>=4){
			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: 100
Accepted
time: 1ms
memory: 5544kb

input:

3
1
111
110110
1101010
1111
111111

output:

-1
26
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
18
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

result:

ok Haitang Suki (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 5544kb

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:

14
3 4
4 5
1 2
3 4
2 3
1 2
3 4
2 3
1 2
3 4
2 3
1 2
1 2
2 3
-1
14
1 2
2 3
3 4
1 2
3 4
2 3
1 2
3 4
2 3
1 2
3 4
2 3
1 2
2 3
13
1 2
1 2
3 4
2 3
1 2
3 4
2 3
1 2
1 2
2 3
1 2
1 2
2 3
6
1 2
1 2
1 2
1 2
1 2
2 3
8
2 3
3 4
1 2
3 4
2 3
1 2
3 4
2 3
11
2 3
4 5
1 2
3 4
2 3
1 2
3 4
2 3
1 2
3 4
2 3
4
2 3
1 2
3 4
2 3...

result:

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