QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#793100 | #9802. Light Up the Grid | oyasumi_sion | TL | 0ms | 0kb | C++20 | 1.7kb | 2024-11-29 16:42:16 | 2024-11-29 22:58:20 |
Judging History
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