QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#793100#9802. Light Up the Gridoyasumi_sionTL 0ms0kbC++201.7kb2024-11-29 16:42:162024-11-29 22:58:20

Judging History

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

  • [2024-11-29 22:58:20]
  • 管理员手动重测本题所有提交记录
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-29 16:42:17]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-11-29 16:42:16]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n;
    std::cin >> n;

    auto lowbit = [&] (i64 x) -> i64 {
        return x & (-x);
    };
    auto update = [&] (i64 x, i64 k, std::vector<int>& c) {
        for (int i = x; i <= n; i += lowbit(i)) c[i] += k;
    };
    auto query = [&](i64 x, std::vector<int>& c) -> i64 {
        i64 ans = 0;
        for (int i = x; i; i -= lowbit(i)) ans += c[i];
        return ans;
    };

    std::vector<int> a(n + 1), b(n + 1);
    i64 ans1 = 0, ans2 = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        std::cin >> x;
        ans1 += query(x, a);
        update(x, 1, a);
    } 
    for (int i = 1; i <= n; i++) {
        int x;
        std::cin >> x;
        ans2 += query(x, b);
        update(x, 1, b);
    }

    ans = ans1 + ans2;
    if (ans & 1) {
        std::cout << "A";
    } else {
        std::cout << "B";
    }
    for (int i = 1; i < n; i++) {
        char t;
        i64 l, r, d;
        std::cin >> t >> l >> r >> d;
        if (t == 'A') {
            i64 tmp = (r - l) * d;
            if (tmp & 1) {
                ans1++;
            }
        } else {
            i64 tmp = (r - l) * d;
            if (tmp & 1) {
                ans2++;
            }
        }
        ans = ans1 + ans2;
        if (ans & 1) {
            std::cout << "A";
        } else {
            std::cout << "B";
        }
    }
    std::cout << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

详细

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: