QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#209731 | #7102. Live Love | PetroTarnavskyi# | RE | 0ms | 0kb | C++17 | 1.2kb | 2023-10-10 16:53:03 | 2023-10-10 16:53:04 |
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
LL cntInv(const VI& a, int l, int r)
{
LL res = 0;
FOR(i, l, r)
FOR(j, i + 1, r)
if (a[i] > a[j])
res++;
return res;
}
void solve()
{
int n;
cin >> n;
vector<int> a(n);
for (int& x : a)
cin >> x;
set<int> used = {-1, n};
multiset<LL> s = {cntInv(a, 0, n)};
FOR(i, 0, n)
{
assert(!s.empty());
LL z = *prev(s.end());
cout << z << " ";
LL p;
cin >> p;
p ^= z;
p--;
assert(0 <= p && p < n);
auto it = used.lower_bound(p);
assert(it != used.begin());
s.erase(s.find(cntInv(a, *prev(it) + 1, *it)));
s.insert(cntInv(a, *prev(it) + 1, p));
s.insert(cntInv(a, p + 1, *it));
used.insert(p);
}
cout << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
int t;
cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
5 5 4 100 50 252 52 3 0 10 10