QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#545565#7789. Outro: True Love WaitshhdhhWA 1ms3600kbC++232.3kb2024-09-03 15:02:002024-09-03 15:02:01

Judging History

你现在查看的是最新测评结果

  • [2024-09-03 15:02:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-09-03 15:02:00]
  • 提交

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=m/2;
    LL sum=getd(p);
    //  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)

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

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: 3556kb

input:

1
0 0 1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3600kb

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:

78
59
69
70
36
38
39
24
32
60
24
29
69
12
45
52
37
8
29
64
22
39
54
69
65
27
33
76
34
39
57
34
81
36
23
70
69
36
39
23
29
42
69
54
27
0
63
8
29
15
10
37
80
24
37
59
71
34
23
31
21
34
23
48
21
47
28
44
42
24
37
75
59
29
55
39
29
28
29
70
55
37
54
47
24
39
79
60
29
26
64
58
32
27
29
37
7
68
42
44

result:

wrong answer 5th numbers differ - expected: '15', found: '36'