QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#543728 | #7789. Outro: True Love Waits | lihuaijiao | WA | 1ms | 7668kb | C++14 | 2.6kb | 2024-09-01 19:07:49 | 2024-09-01 19:07:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll ,ll > PII;
const ll N=1e6+10;
const ll mod=1e9+7;
ll a[N];
ll cnt=0;
ll b[N];
ll bb[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll t;
cin>>t;
b[0]=1;
bb[0]=0;
for(ll i=1;i<=100;i++){
b[i]=b[i-1]*4%mod;
bb[i]=bb[i-1]+b[i];
bb[i]%=mod;
// cout<<"bb["<<i<<"]="<<bb[i]<<endl;
}
while(t--){
string s,t;
cin>>s>>t;
ll k;
cin>>k;
cnt=1;
ll lens=s.length()-1,lent=t.length()-1;
if(lens>lent){
for(ll i=0;i<=lent;i++){
a[cnt++]=(s[lens-i]-'0')^(t[lent-i]-'0');
}
for(ll i=lens-lent-1;i>=0;i--){
a[cnt++]=(s[i]-'0');
}
cnt--;
}
else{
for(ll i=0;i<=lens;i++){
a[cnt++]=(s[lens-i]-'0')^(t[lent-i]-'0');
}
for(ll i=lent-lens-1;i>=0;i--){
a[cnt++]=(t[i]-'0');
}
cnt--;
}
// ll f=0;
while(cnt>=0 && a[cnt]==0) cnt--;
if(cnt<0){
cout<<bb[k-1]<<endl;
continue;
}
if(cnt%2==1){
cnt++;
a[cnt]=0;
}
ll ans=0;
ll dep=cnt/2-1;
ans+=bb[dep];
ll kk=0;
// cout<<cnt<<endl;
// for(ll i=1;i<=cnt;i++){
// cout<<a[i];
// }
// cout<<endl;
for(ll i=1;i<=cnt;i+=2){
if(a[i]==0 && a[i+1]==0) kk++;
else break;
}
ll sec=kk+1;
// cout<<ans<<endl;
// cout<<kk<<endl;
while(cnt){
if(a[cnt]==1 && a[cnt-1]==1){
ans+=bb[dep]*2+2;
ans%=mod;
dep--;
cnt-=2;
}
else if(a[cnt]==0 && a[cnt-1]==1){
ans+=1;
ans%=mod;
dep--;
cnt-=2;
}
else if(a[cnt]==0 && a[cnt-1]==0){
dep--;
cnt-=2;
}
else{
ans+=bb[dep]*3+3;
ans%=mod;
dep--;
cnt-=2;
}
// cout<<ans<<endl;
}
if(k>sec) cout<<-1<<endl;
else{
// cout<<ans<<endl;
ans+=bb[k-1];
ans%=mod;
cout<<ans<<endl;
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7668kb
input:
4 1 10 1 1 10 2 100 0 2 11 11 3
output:
2 -1 9 20
result:
ok 4 number(s): "2 -1 9 20"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7608kb
input:
1 0 0 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 7644kb
input:
100 110111 11111 1 10110 101101 1 11010 111111 1 100110 1 1 10010 11010 1 1100 10111 1 100100 111110 1 101110 101100 1 1011 10110 1 110100 1110 1 11010 11000 1 11110 1000 1 111000 11101 1 110 1001 1 101010 11000 1 10 111110 1 110001 101000 1 1010 1000 1 10101 11 1 111011 11010 1 110001 100000 1 1100...
output:
98 79 85 86 19 38 39 3 32 80 3 25 85 16 65 72 37 3 25 84 22 39 74 85 85 23 33 96 34 22 77 17 101 19 23 86 85 36 22 23 25 62 85 74 6 0 83 3 25 19 14 20 100 24 37 79 87 17 23 31 21 34 23 64 21 63 7 64 62 3 37 95 79 25 75 39 25 24 25 86 75 20 74 63 24 22 99 80 8 22 84 78 32 6 8 37 2 84 62 64
result:
wrong answer 1st numbers differ - expected: '78', found: '98'