QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#570951#8058. Binary vs TernaryFluoresceWA 1ms3880kbC++201.9kb2024-09-17 19:22:192024-09-17 19:22:23

Judging History

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

  • [2024-09-17 19:22:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3880kb
  • [2024-09-17 19:22:19]
  • 提交

answer

#include<bits/stdc++.h>
#include<unordered_map>
typedef long long ll;
typedef long double ld;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 5e5 + 10, M = 4e6+10, mod = 998244353;
const ll inf = 1e18;
const ld eps = 1e-8;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy;
void bout(bool f) {
    if (f)cout << "Yes\n";
    else cout << "No\n";
}
ll n, m, k,p,p1,p2;
string s,t;
vec<PII> ans;

void cla(){
	for(int i=p1+1;i<n;++i){
		if(s[i]=='0'){
			ans.pushk({p2+1,p2+2});
		}else{
			ans.pushk({p2,p2+1});
			ans.pushk({p2+1,p2+3});
		}
	}
}

void imp(){
	if(s.back()=='0')ans.pushk({p2,p2+1});
	for(int i=m;i>p2;--i){
		ans.pushk({p2,p2+1});
		if(t[i]=='0'){
			ans.pushk({p2,p2+1});
		}else{
			ans.pushk({p2,p2+1});
			ans.pushk({p2+1,p2+2});
		}
	}
	ans.pushk({p2,p2+1});
	ans.pushk({p2+1,p2+3});
}

void solve() {
	ans.clear();
    cin>>s>>t;
    n=s.length(),m=t.length();
    s='#'+s;
    t='#'+t;
    p1=n,p2=m;
    for(int i=1;i<=n;++i){
    	if(s[i]!='0'){
    		p1=i;
    		break;
		}
	}
	for(int i=1;i<=m;++i){
		if(t[i]!='0'){
			p2=i;
			break;
		}
	}
	if(p1<p2||((p1==n)^(p2==m))){
		cout<<-1<<'\n';
		return;
	}
	if(p1>p2){
		ans.pushk({p2,p1});
	}
	cla();
	imp();
	cout<<ans.size()<<'\n';
	for(int i=0;i<ans.size();++i){
		cout<<ans[i].ft<<' '<<ans[i].sd<<'\n';
	}
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    streambuf* cinbackup = cin.rdbuf(), * coubackup = cout.rdbuf();
    ifstream fin("in.txt");
    ofstream fout("out.txt");
    cin.rdbuf(fin.rdbuf());
    cout.rdbuf(fout.rdbuf());
#endif
    int _ = 1, __ = 1;
    cin >> _;
    __ = _;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3880kb

input:

3
1
111
110110
1101010
1111
111111

output:

-1
25
1 2
2 4
2 3
1 2
2 4
1 2
2 4
1 2
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
1 2
2 3
1 2
2 4
21
1 2
2 4
1 2
2 4
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
1 2
2 3
1 2
2 4

result:

ok Haitang Suki (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3620kb

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
1 2
2 4
1 2
2 4
2 3
1 2
1 2
1 2
2 3
1 2
1 2
2 3
1 2
2 4
-1
7
2 3
2 3
2 3
1 2
1 2
1 2
2 4
14
2 3
1 2
2 4
1 2
1 2
2 3
1 2
1 2
2 3
1 2
1 2
2 3
1 2
2 4
11
1 2
1 2
1 2
1 2
1 2
2 3
1 2
1 2
2 3
1 2
2 4
9
1 2
2 4
2 3
1 2
1 2
1 2
2 3
1 2
2 4
11
1 2
2 4
2 3
1 2
2 4
1 2
1 2
1 2
2 3
1 2
2 4
8
1 2
2 4
1 2
1 2...

result:

wrong answer (l,r) is invalid (test case 34)