QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789039#9802. Light Up the Griducup-team5071#TL 0ms0kbC++201.7kb2024-11-27 19:08:082024-11-27 19:08:08

Judging History

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

  • [2024-11-27 19:08:08]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-27 19:08:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
void Solve()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1), t(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i];
    auto lowbit = [&](int x) -> int
    {
        return x & (-x);
    };
    auto add = [&](int x, int y) -> void
    {
        for (; x <= n; x += lowbit(x))
            t[x] += y;
    };
    auto ask = [&](int x) -> int
    {
        int res;
        for (; x; x -= lowbit(x))
            res += t[x];
        return res;
    };
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += ask(n) - ask(a[i]);
        add(a[i], 1);
    }
    for (int i = 1; i <= n; i++)
        t[i] = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += ask(n) - ask(b[i]);
        add(b[i], 1);
    }
    ans %= 2;
    auto print = [&]() -> void
    {
        if (ans)
            cout << "A";
        else
            cout << "B";
    };
    print();
    for (int i = 1; i < n; i++)
    {
        char op;
        cin >> op;
        int l, r, x;
        cin >> l >> r >> x;
        int len = r - l + 1;
        x %= r - l + 1;
        ans ^= (((len - x) * x) & 1);
        print();
    }
    cout << "\n";
}
signed main()
{
    // ios::sync_with_stdio(false), cin.tie(0);
    int T;
    cin >> T;
    while (T--)
        Solve();
    return 0;
}
/*
5
3
1 2 3
1 2 3
A 1 1 1
B 1 1 1
3
1 2 3
2 1 3
A 1 2 1
B 2 2 1
3
1 2 3
2 1 3
A 1 3 1
B 1 2 1
3
1 2 3
3 2 1
A 2 2 1
B 2 3 1
10
1 2 34 5 6 7 89 10
4 2 39 6 1 5 87 10
A 2 9 10
B 2 7 9
A 1 10 8
B 4 6 7
B 3 10 6
A 2 5 5
A 8 9 4
B 3 9 3
A 2 7 2
*/

详细

Test #1:

score: 0
Time Limit Exceeded

input:

2 1000 100 10 1
4
10
00

01
00

00
10

00
01
1
11
11

output:


result: