QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#631065#7789. Outro: True Love WaitsMrlaoluWA 0ms3588kbC++202.3kb2024-10-11 21:46:022024-10-11 21:46:20

Judging History

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

  • [2024-10-11 21:46:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-10-11 21:46:02]
  • 提交

answer

//
// Created by Mrlaolu on 2024/7/10.
//

#include<bits/stdc++.h>

#define int long long
#define endl '\n'
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define x first
#define y second
#define lc root<<1
#define rc root<<1|1
const int N = 1e5+2;
const int MOD = 1e9+7;
using namespace std;
using PII = pair<int,int>;
using i128 = __int128;
#define debug0

int qpow(int x,int n,int p){
    int ans = 1;
    while(n){
        if(n & 1)ans = (ans * x) % p;
        x = (x * x) % p;
        n >>= 1;
    }
    return ans;
}

void solve(){
    string s,t;cin >> s >> t;
    int ans = 0;
    if(s != "0" && t == "0")ans++;
    int k;cin >> k;
    string f;
    if(s.size() > t.size()){
        string k;
        for(int i = 0;i < s.size() - t.size();++i){
            k += '0';
        }
        t = k + t;
    }else if(s.size() < t.size()){
        string k;
        for(int i = 0;i < t.size() - s.size();++i){
            k += '0';
        }
        s = k + s;
    }
    for(int i = 0;i < s.size();++i){
        f += '0' + (s[i] != t[i]);
    }

    if(f.size() & 1)f = '0' + f;
    int len = 0;
    while(len < f.size()){
        if(f[f.size() - 1 - len] != '0')break;
        len++;
    }
//    cout << len << endl;
//    if(len == s.size())len = INT_MAX;
    if(k - 1 > len / 2 && len != f.size()){cout << -1 << endl;return;}
//    vector<int>p = {0,1,3,2};
    int cnt = 0;
//    cout << f << endl;
    for(int i = f.size() - 1;i >= 0;i -= 2){
        if(f[i] == '1' && f[i-1] == '0')ans = (ans + (1ll * qpow(4,cnt,MOD)) % MOD) % MOD;
        if(f[i] == '1' && f[i-1] == '1')ans = (ans + (2ll * qpow(4,cnt,MOD)) % MOD) % MOD;
        if(f[i] == '0' && f[i-1] == '1')ans = (ans + (3ll * qpow(4,cnt,MOD)) % MOD) % MOD;
        ++cnt;
    }

//    cout << ans << endl;
    ans = (ans + 4ll * ((qpow(4,k - 1,MOD) - 1 + MOD) % MOD) % MOD *
            qpow(3,MOD-2,MOD) % MOD ) % MOD;
    cout << ans << endl;

}

#define FILE
#define MULTI

signed main() {


#ifndef ONLINE_JUDGE
#ifdef FILE
    freopen("in.txt", "r",stdin);
    freopen("out.txt", "w",stdout);
#endif
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;

#ifdef MULTI
    cin >> T;
#endif

    while (T--) {
        solve();

    }
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0ms
memory: 3556kb

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:

60
46
53
54
12
30
31
3
25
47
3
23
53
10
35
40
29
3
23
49
17
31
42
53
50
21
26
59
27
15
44
11
63
12
18
54
53
28
15
18
23
32
53
42
5
0
48
3
23
12
9
13
62
19
29
46
55
11
18
24
16
27
18
37
16
36
6
34
32
3
29
58
46
23
43
31
23
22
23
54
43
13
42
36
19
15
61
47
7
20
49
45
25
5
7
29
2
52
32
34

result:

wrong answer 1st numbers differ - expected: '78', found: '60'