QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#209731#7102. Live LovePetroTarnavskyi#RE 0ms0kbC++171.2kb2023-10-10 16:53:032023-10-10 16:53:04

Judging History

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

  • [2023-10-10 16:53:04]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-10 16:53:03]
  • 提交

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

output:


result: