QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350664#8058. Binary vs TernaryWhimsicalWA 1ms3800kbC++141.5kb2024-03-10 23:06:112024-03-10 23:06:12

Judging History

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

  • [2024-03-10 23:06:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3800kb
  • [2024-03-10 23:06:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll t;cin>>t;
	while(t--){
		string a,b;cin>>a>>b;
		if(a=="0"||a=="1"||b=="0"||b=="1"||b=="10"){
			if(a!=b)cout<<"-1\n";
			else cout<<"0\n";
			continue;
		}

		vector<pii> ops;

		rep(i,1,sz(a)){
			if(a[i]=='0'){
				ops.push_back({i-1,i});
				a[i]=='1';
			}
		}

		rep(i,0,sz(a)-2){
			ops.push_back({0,1});
			ops.push_back({2,3});
			ops.push_back({1,2});
		}

		if(b=="11"){
			cout<<sz(ops)<<"\n";
			rep(i,0,sz(ops))cout<<ops[i].first+1<<" "<<ops[i].second+1<<"\n";
			continue;
		}

		//reverse(all(b));
		for(int i=sz(b)-1;i>=3;--i){
			if(b[i]=='0'){
				ops.push_back({0,1});
				ops.push_back({0,1});
			}if(b[i]=='1'){
				ops.push_back({0,1});
				ops.push_back({0,1});
				ops.push_back({1,2});
			}
		}
		if(b[1]=='1'){
			ops.push_back({0,1});
			ops.push_back({0,1});
			if(b[2]=='1')ops.push_back({1,2});
		}else if (b[2]=='0'){
			ops.push_back({0,1});
		}else{
			ops.push_back({0,1});
			ops.push_back({0,1});
			ops.push_back({1,2});
			ops.push_back({0,1});
			ops.push_back({2,3});
		}

		cout<<sz(ops)<<"\n";
		rep(i,0,sz(ops))cout<<ops[i].first+1<<" "<<ops[i].second+1<<"\n";
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3788kb

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: 1ms
memory: 3800kb

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
-1
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
-1
-1
10
1 2
1 2
1 2
2 3
1 2
1 2
2 3
1 2
1 2
2 3
17
1 2...

result:

wrong answer Pans=-1, Jans!=-1 (test case 3)