QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#570924#8058. Binary vs TernaryFluoresceWA 0ms3504kbC++201.9kb2024-09-17 19:09:452024-09-17 19:09:46

Judging History

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

  • [2024-09-17 19:09:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3504kb
  • [2024-09-17 19:09:45]
  • 提交

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,p2+1});
		}
	}
	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: 0
Wrong Answer
time: 0ms
memory: 3504kb

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

result:

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