QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722946 | #7789. Outro: True Love Waits | harlem | WA | 3ms | 14784kb | C++14 | 1.4kb | 2024-11-07 20:42:11 | 2024-11-07 20:42:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
const ll mod=1e9+7;
string s,t;int k;
int xo[N],so[N/2];
ll sk[N];
ll ans;
int tim[4]={0,1,3,2};
void init(int num){
ll tad=1;
sk[0]=tad;
for(int i=1;i<=num;i++){
tad=tad*4%mod;
sk[i]=(sk[i-1]+tad)%mod;
}
}
void solve(){
ans=0;
cin>>s>>t>>k;
reverse(s.begin(),s.end());
reverse(t.begin(),t.end());
int n=max(s.size(),t.size());
for(int i=0;i<n;i++){
if(i>=s.size())xo[i]=t[i]-'0';
else if(i>=t.size())xo[i]=s[i]-'0';
else xo[i]=(s[i]-'0')^(t[i]-'0');
so[i]=0;
}
int m=-1,zr=0;
for(int i=0;i<n;i++){
if(i&1)(so[i>>1]|=(xo[i]<<1));
else (so[i>>1]|=xo[i]);
if(so[i>>1]>0){
m=(i>>1);
if(zr==-1)zr=i;
}
}
m++;
if(m==0&&so[0]==0){
cout<<sk[k-1]-sk[0]<<"\n";
return;
}
// cout<<k<<" "<<zr<<"\n";
if(k>zr+1){
cout<<-1<<"\n";
return;
}
for(int i=0;i<m;i++){
ans=(ans+sk[i]*tim[so[i]]%mod)%mod;
}
ans=(ans+sk[k-1]-sk[0])%mod;
cout<<ans<<"\n";
}
int main(){
// freopen("wait.in","r",stdin);
// freopen("wait.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
init(1e6);
int t;cin>>t;
while(t--)solve();
return 0;
}
/*
1
100 0 2
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 14784kb
input:
4 1 10 1 1 10 2 100 0 2 11 11 3
output:
2 -1 -1 20
result:
wrong answer 3rd numbers differ - expected: '9', found: '-1'