QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#570973 | #8058. Binary vs Ternary | Fluoresce | WA | 1ms | 3644kb | C++20 | 2.0kb | 2024-09-17 19:30:44 | 2024-09-17 19:30:45 |
Judging History
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});
}
if(p1==n&&p2==m){
if(p1==p2)cout<<0;
else cout<<1<<'\n'<<p2<<' '<<p1<<'\n';
return;
}
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: 3632kb
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: 3644kb
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 output format Expected integer, but "0-1" found (test case 34)