QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#789039 | #9802. Light Up the Grid | ucup-team5071# | TL | 0ms | 0kb | C++20 | 1.7kb | 2024-11-27 19:08:08 | 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