QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#177375#6128. Flippy SequenceTJ_AndevikingWA 57ms14256kbC++201.4kb2023-09-12 21:55:362023-09-12 21:55:36

Judging History

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

  • [2023-09-12 21:55:36]
  • 评测
  • 测评结果:WA
  • 用时:57ms
  • 内存:14256kb
  • [2023-09-12 21:55:36]
  • 提交

answer

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128_t int128;
typedef pair<int, int> pii;
#define iofast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) (x&(-x))
#define inv(x) qpow(x,mod-2)
#define debug(x) cout << (#x) << " = " << x << endl
#define range(x) (x).begin(), (x).end()

const int iINF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;

/*---------------------------------------*/

void solve()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    if (s == t)
        cout << 1ll * n * (n + 1) / 2 << '\n';
    else {
        vector<int>v;
        for (int i = 0;i < n;i++)
            v.push_back((s[i] - '0') ^ (t[i] - '0'));
        v.erase(unique(range(v)), v.end());
        int cnt = accumulate(range(v), 0);

        if (cnt > 2)
            cout << "0\n";
        else if (cnt == 2)
            cout << "6\n";
        else {
            v.clear();
            for (int i = 0;i < n;i++)
                v.push_back((s[i] - '0') ^ (t[i] - '0'));
            cnt = accumulate(range(v), 0);
            cout << 2 * (cnt - 1) << '\n';
        }
    }
}

/*---------------------------------------*/

int main()
{
    iofast;
    int t = 1;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
1
0
2
00
11
5
01010
00111

output:

0
2
6

result:

ok 3 number(s): "0 2 6"

Test #2:

score: -100
Wrong Answer
time: 57ms
memory: 14256kb

input:

126648
1
0
0
1
1
0
2
01
01
2
01
11
2
10
11
2
11
00
3
011
011
3
010
110
3
011
001
3
111
001
3
001
000
3
101
000
3
011
000
3
111
000
4
1111
1111
4
1110
0110
4
0010
0110
4
1011
0111
4
1001
1011
4
0100
1110
4
0000
0110
4
0111
1001
4
1001
1000
4
1011
0010
4
0001
0100
4
1000
0101
4
0100
0111
4
1101
0110
4...

output:

1
0
3
0
0
2
6
0
0
2
0
6
2
4
10
0
0
2
0
6
2
4
0
6
6
6
2
6
4
6
15
0
0
2
0
6
2
4
0
6
6
6
2
6
4
6
0
6
6
6
6
0
6
6
2
6
6
6
4
6
6
8
21
0
0
2
0
6
2
4
0
6
6
6
2
6
4
6
0
6
6
6
6
0
6
6
2
6
6
6
4
6
6
8
0
6
6
6
6
0
6
6
6
0
0
0
6
0
6
6
2
6
6
6
6
0
6
6
4
6
6
6
6
6
8
10
28
0
0
2
0
6
2
4
0
6
6
6
2
6
4
6
0
6
6
6
6
0...

result:

wrong answer 4th numbers differ - expected: '2', found: '0'