QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#545549 | #7789. Outro: True Love Waits | hhdhh | WA | 1ms | 3844kb | C++23 | 2.3kb | 2024-09-03 14:55:21 | 2024-09-03 14:55:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
#define rept(i, a, ne) for(int i = (a); ~i ; i=ne[i])
#define debug(x) cout<<#x<<": "<<x<<endl
#define fi first
#define sec second
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int,int>PII;
LL mod=1e9+7;
LL qmi(LL a,LL b)
{
LL sum=1;
while(b)
{
if(b&1)sum=sum*a%mod;
a=a*a%mod;
b>>=1;
}
return sum;
}
LL getd(LL n)
{
return (mod+1-qmi(4,n))*qmi(-3+mod,mod-2)%mod;
}
void slove()
{
string s,t;
cin>>s>>t;
int k;
cin>>k;
reverse(s.begin(),s.end());
reverse(t.begin(),t.end());
int n=s.size(),m=t.size();
if(n>m)
swap(s,t),swap(n,m);
rep(i,0,n-1)
t[i]=(t[i]^s[i])+'0';
// debug(t);
int num=0;
rep(i,0,m-1)
{
if(t[i]=='0')
num++;
else
break;
}
if(num==m)
{
LL sum=getd(k)-1;
sum=(sum+mod)%mod;
cout<<sum<<endl;
return ;
}
if(k>1+num/2)
{
cout<<-1<<endl;
return ;
}
if(m%2)
m++,t+='0';
// debug(t);
int p=num/2;
LL sum=getd(p+1);
// debug(sum);
int ds=1;
for(int i=0;i<m;i+=2)
{
ds=getd(i/2+1)%mod;
int s=t[i]-'0'+2*(t[i+1]-'0');
if(i==m-2)
{
if(s==1)
sum+=0;
else if(s==3)
sum+=ds;
else if(s==2)
sum+=ds*2%mod;
continue;
}
if(s==0)
sum+=0;
else if(s==1)
sum+=ds;
else if(s==3)
sum+=ds*2%mod;
else
sum+=ds*3%mod;
sum%=mod;
}
// debug(sum);
// debug(getd(k));
sum+=getd(k)-1;
sum=(sum+mod)%mod;
cout<<sum<<endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
// cout << fixed << setprecision(9);
int t=1;
cin>>t;
while(t--)
{
slove();
}
return 0;
}
//#pragma GCC optimize(2)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 0ms
memory: 3780kb
input:
1 0 0 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3844kb
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:
62 39 49 50 20 18 19 4 12 40 4 9 49 8 25 36 17 4 9 44 2 19 34 49 45 7 13 56 14 19 41 14 61 20 3 50 49 20 19 3 9 42 49 34 7 0 63 4 9 15 10 17 60 4 17 39 51 14 3 15 21 14 3 28 21 31 8 24 42 4 17 55 39 9 35 19 9 8 9 50 35 17 34 31 4 19 59 40 9 10 44 38 12 7 9 17 3 52 42 24
result:
wrong answer 1st numbers differ - expected: '78', found: '62'