QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#767109 | #7789. Outro: True Love Waits | i0stream | WA | 0ms | 3816kb | C++14 | 980b | 2024-11-20 19:50:55 | 2024-11-20 19:50:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll P=1e9+7;
string s,t;
ll k,ans,T;
ll fpow(ll b,ll t){
ll c=1;
do{
if (t&1) c=c*b%P;
b=b*b%P;
}while (t>>=1);
return c;
}
int main(){
scanf("%lld",&T);
while (T--){
ans=0;
cin>>s>>t;scanf("%lld",&k);
if (s.size()>t.size()) swap(s,t);
if (t.size()&1) t='0'+t;
while (s.size()<t.size()) s='0'+s;
int ps=(int)(s==t),l=t.size();
for (int i=0;i<l;i++) t[i]=48+(s[i]-48^t[i]-48);
ll inc=1,cnt=0;
for (int i=l-2,j=0;i>=0;i-=2,j++){//t[i],t[i+1]
ll op=0;
if (t[i]=='0' && t[i+1]=='0') op=0;
if (t[i]=='0' && t[i+1]=='1') op=1;
if (t[i]=='1' && t[i+1]=='1') op=2;
if (t[i]=='1' && t[i+1]=='0') op=3;
if (op==0 && inc) cnt++;
if (op!=0) inc=0;
ans=(ans+fpow(5,j)*op%P)%P;
}
if (k>cnt+1 && !ps) puts("-1");
else{
for (int j=1;j<=k-1;j++) ans=(ans+fpow(4,j))%P;
printf("%lld\n",ans);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: 3816kb
input:
1 0 0 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3812kb
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:
90 67 81 82 15 42 43 3 36 68 3 33 81 12 53 60 41 3 33 76 26 43 62 81 77 31 37 88 38 18 65 13 93 15 27 82 81 40 18 27 33 50 81 62 6 0 75 3 33 15 10 16 92 28 41 67 83 13 27 35 25 38 27 56 25 55 7 52 50 3 41 87 67 33 63 43 33 32 33 82 63 16 62 55 28 18 91 68 8 30 76 66 36 6 8 41 2 80 50 52
result:
wrong answer 1st numbers differ - expected: '78', found: '90'