QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#733261 | #8058. Binary vs Ternary | YaeMik0 | WA | 0ms | 3620kb | C++23 | 1.6kb | 2024-11-10 17:58:34 | 2024-11-10 17:58:36 |
Judging History
answer
#include<bits/stdc++.h>
#define INF 2147483647LL
#define int long long
#define MAXN 300005
#define mod 1000000007
#define PI 3.14
#define eps 1e-10
#define pa pair<int,int>
#define ms(a,x) memset(a,x,sizeof(a))
#define mc(ar1,ar2) memcpy(ar1,ar2,sizeof(ar2))
#define mkp(a,b) make_pair(a,b)
#define ls (p<<1)
#define rs (p<<1|1)
#define fn(i,st,ed) for(int i=st;i<=ed;++i)
#define fd(i,st,ed) for(int i=st;i>=ed;--i)
#define fg(i,x,head,e) for(int i=head[x];~i;i=e[i].nxt)
using namespace std;
inline int read(){int x=0,f=1;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}while(isdigit(c)){x=x*10+c-'0';c=getchar();}return x*f;}
vector<pa>v;
void solve(){
string s1,s2;cin>>s1>>s2;
if((s1=="1")^(s2=="1")){cout<<-1<<endl;return;}
int n1=s1.size(),n2=s2.size(),ans=0;
fn(i,1,n1-1)if(s1[i]=='0'){
ans++;
v.push_back({i,i+1});
}
if(n1<n2)fn(i,n1-1,n2-2){
ans+=3;
v.push_back({i,i+1});
v.push_back({i,i+1});
v.push_back({i+1,i+2});
}
else if(n1>n2){
fd(i,n2-1,n1-1){
ans++;
v.push_back({i-1,i});
}
ans+=2;
v.push_back({n2,n2+(n2-n1+1)*2-1});
v.push_back({n2-1,n2});
}
fd(i,n2-1,0)if(s2[i]=='0'){
ans+=2;
v.push_back({i,i+1});
v.push_back({i+1,i+2});
}
cout<<ans<<endl;
for(auto i:v)cout<<i.first<<' '<<i.second<<endl;
v.clear();
}
signed main(){
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: 0ms
memory: 3620kb
input:
3 1 111 110110 1101010 1111 111111
output:
-1 11 2 3 5 6 5 6 5 6 6 7 6 7 7 8 4 5 5 6 2 3 3 4 6 3 4 3 4 4 5 4 5 4 5 5 6
result:
ok Haitang Suki (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3508kb
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:
4 3 4 4 5 3 0 2 3 -1 7 1 2 2 3 3 4 2 -3 1 2 1 2 2 3 1 1 2 9 1 2 1 2 1 2 2 3 2 3 2 3 3 4 3 4 4 5 4 2 3 3 4 2 -1 1 2 4 2 3 4 5 2 -3 1 2 3 2 3 2 1 1 2 -1 6 1 2 4 5 2 -3 1 2 1 2 2 3 10 1 2 1 2 1 2 2 3 2 3 2 3 3 4 3 4 3 4 4 5 10 1 2 2 3 3 4 4 5 4 3 3 4 2 3 3 4 1 2 2 3 -1 11 1 2 1 2 2 3 2 3 2 3 3 4 3 4 3 ...
result:
wrong answer Integer parameter [name=r] equals to 0, violates the range [1, 128] (test case 1)