QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#507994#8642. Spy 3green_gold_dog0 77ms5912kbC++205.4kb2024-08-07 01:45:122024-08-07 01:45:13

Judging History

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

  • [2024-08-07 01:45:13]
  • 评测
  • 测评结果:0
  • 用时:77ms
  • 内存:5912kb
  • [2024-08-07 01:45:12]
  • 提交

Aoi

#include<bits/stdc++.h>
#include "Aoi.h"

using namespace std;

typedef int ll;
typedef long long lll;

const lll INF = 1'000'000'000'000'000'000, COL2 = 5;

struct DSU {
	vector<ll> p, sz;
	DSU(ll n) {
		p.resize(n);
		sz.resize(n, 1);
		for (ll i = 0; i < n; i++) {
			p[i] = i;
		}
	}
	ll get(ll x) {
		return (p[x] == x ? x : p[x] = get(p[x]));
	}
	void unite(ll a, ll b) {
		a = get(a);
		b = get(b);
		if (a == b) {
			return;
		}
		if (sz[a] < sz[b]) {
			swap(a, b);
		}
		p[b] = a;
		sz[a] += sz[b];
	}
};

ll merge(ll a, ll b, ll& lst, string& ans) {
	if (a == 0) {
		return b;
	}
	if (b == 0) {
		return a;
	}
	for (ll i = 0; i < COL2; i++) {
		ans.push_back('0' + ((a >> i) & 1));
	}
	for (ll i = 0; i < COL2; i++) {
		ans.push_back('0' + ((b >> i) & 1));
	}
	lst++;
	return lst;
}

ll dfs(ll v, vector<vector<pair<ll, lll>>>& arr, vector<ll>& isdel, vector<ll>& num, vector<ll>& snum, ll& lst, string& ans) {
	ll now = snum[v];
	for (auto[i, _] : arr[v]) {
		now = merge(now, dfs(i, arr, isdel, num, snum, lst, ans), lst, ans);
	}
	if (isdel[v] != -1) {
		num[isdel[v]] = now;
	}
	return now;
}

string aoi(ll n, ll m, ll q, ll k, vector<ll> a, vector<ll> b, vector<lll> c, vector<ll> t, vector<ll> x) {
	string ans;
	vector<lll> dist(n, INF);
	vector<vector<pair<ll, lll>>> arr(n);
	for (ll i = 0; i < m; i++) {
		arr[a[i]].emplace_back(b[i], c[i]);
		arr[b[i]].emplace_back(a[i], c[i]);
	}
	map<ll, ll> del;
	for (ll i = 0; i < k; i++) {
		del[x[i]] = i;
	}
	priority_queue<pair<ll, lll>, vector<pair<ll, lll>>, greater<pair<ll, lll>>> pq;
	pq.emplace(0, 0);
	dist[0] = 0;
	while (!pq.empty()) {
		auto[v, d] = pq.top();
		pq.pop();
		if (dist[v] != d) {
			continue;
		}
		for (auto[i, c] : arr[v]) {
			if (d + c < dist[i]) {
				dist[i] = d + c;
				pq.emplace(i, d + c);
			}
		}
	}
	DSU d(n);
	vector<tuple<ll, ll, lll, ll>> nr;
	vector<ll> isdel(n, -1);
	for (ll i = 0; i < n; i++) {
		arr[i].clear();
	}
	for (ll i = 0; i < m; i++) {
		if (d.get(a[i]) == d.get(b[i])) {
			continue;
		}
		if (dist[b[i]] == dist[a[i]] + c[i]) {
			nr.emplace_back(a[i], b[i], c[i], i);
			arr[a[i]].emplace_back(b[i], c[i]);
			if (del.find(i) != del.end()) {
				isdel[b[i]] = del[i];
			}
			d.unite(a[i], b[i]);
		}
		if (dist[a[i]] == dist[b[i]] + c[i]) {
			nr.emplace_back(b[i], a[i], c[i], i);
			arr[b[i]].emplace_back(a[i], c[i]);
			if (del.find(i) != del.end()) {
				isdel[a[i]] = del[i];
			}
			d.unite(a[i], b[i]);
		}
	}
	vector<ll> num(k, 0);
	vector<ll> snum(n, 0);
	ll lst = q;
	for (ll i = 0; i < q; i++) {
		snum[t[i]] = i + 1;
	}
	dfs(0, arr, isdel, num, snum, lst, ans);
	for (ll i = 0; i < k; i++) {
		for (ll j = 0; j < COL2; j++) {
			ans.push_back('0' + ((num[i] >> j) & 1));
		}
	}
	return ans;
}

Bitaro

#include<bits/stdc++.h>
#include "Bitaro.h"

using namespace std;

typedef int ll;
typedef long long lll;

const lll INF = 1'000'000'000'000'000'000, COL2 = 5;

void bitaro(ll n, ll m, ll q, ll k, vector<ll> a, vector<ll> b, vector<lll> c, vector<ll> t, vector<ll> x, string s) {
	set<ll> calc;
	calc.insert(0);
	for (auto i : x) {
		calc.insert(a[i]);
		calc.insert(b[i]);
		c[i] = INF + 1;
	}
	for (auto i : t) {
		calc.insert(i);
	}
	vector<vector<tuple<ll, lll, ll>>> arr(n);
	for (ll i = 0; i < m; i++) {
		arr[a[i]].emplace_back(b[i], c[i], i);
		arr[b[i]].emplace_back(a[i], c[i], i);
	}
	vector<vector<lll>> dist(n);
	vector<vector<ll>> p(n);
	for (auto i : calc) {
		dist[i].resize(n, INF);
		dist[i][i] = 0;
		p[i].resize(n, -1);
		priority_queue<pair<ll, lll>, vector<pair<ll, lll>>, greater<pair<ll, lll>>> pq;
		pq.emplace(i, 0);
		while (!pq.empty()) {
			auto[v, d] = pq.top();
			pq.pop();
			if (d != dist[i][v]) {
				continue;
			}
			for (auto[j, c, e] : arr[v]) {
				if (dist[i][j] > d + c) {
					dist[i][j] = d + c;
					p[i][j] = e;
					pq.emplace(j, d + c);
				}
			}
		}
	}
	vector<vector<ll>> nums(1 << COL2);
	for (ll i = 0; i < q; i++) {
		nums[i + 1].push_back(i);
	}
	vector<ll> all;
	while (!s.empty()) {
		ll now = 0;
		for (ll i = 0; i < COL2; i++) {
			now *= 2;
			now += s.back() - '0';
			s.pop_back();
		}
		all.push_back(now);
	}
	for (ll i = q + 1; i < q * 2; i++) {
		ll fir = all.back();
		all.pop_back();
		ll sec = all.back();
		all.pop_back();
		nums[i].resize(nums[fir].size() + nums[sec].size());
		merge(nums[fir].begin(), nums[fir].end(), nums[sec].begin(), nums[sec].end(), nums[i].begin());
	}
	vector<vector<ll>> qs(q);
	for (ll i = 0; i < k; i++) {
		ll now = all.back();
		all.pop_back();
		for (auto j : nums[now]) {
			qs[j].push_back(x[i]);
		}
	}
	for (ll i = 0; i < q; i++) {
		ll now = 0;
		multiset<ll> needs;
		needs.insert(-1);
		for (auto j : qs[i]) {
			needs.insert(j);
		}
		vector<ll> ans;
		while (now != t[i]) {
			lll md = INF;
			ll v = -228;
			bool bb;
			for (auto j : needs) {
				if (j == -1) {
					if (md > dist[now][t[i]]) {
						md = dist[now][t[i]];
						v = j;
					}
					continue;
				}
				if (md > dist[now][a[j]]) {
					md = dist[now][a[j]];
					v = j;
					bb = false;
				}
				if (md > dist[now][b[j]]) {
					md = dist[now][b[j]];
					v = j;
					bb = true;
				}
			}
			needs.erase(v);
			ll nv = (v == -1 ? t[i] : (bb ? b[v] : a[v]));
			vector<ll> ne;
			while (nv != now) {
				ne.push_back(p[now][nv]);
				nv = (a[p[now][nv]] == nv ? b[p[now][nv]] : a[p[now][nv]]);
			}
			reverse(ne.begin(), ne.end());
			for (auto j : ne) {
				ans.push_back(j);
			}
			if (v != -1) {
				ans.push_back(v);
			}
			now = (v == -1 ? t[i] : (bb ? a[v] : b[v]));
		}
		answer(ans);
	}
}

详细

Test #1:

score: 99
Acceptable Answer
time: 77ms
memory: 5912kb

Manager to Aoi

200 19900
13 70 985302938314
120 174 18964037101
18 153 170196070829
45 129 323777973024
62 198 689223413645
88 133 457404464825
19 57 803409835578
22 187 662331177910
18 31 529437059733
161 182 637731822589
109 131 32831735773
109 191 875742441191
43 78 135479410688
56 60 19000632823
44 143 6823771...

Aoi to Manager

A11110101100000101100010010101000110011101100100101010001010110001011011001010000000110010010011110001110000010010111101111101001111101010100101110111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

Manager to Bitaro

200 19900
13 70 985302938314
120 174 18964037101
18 153 170196070829
45 129 323777973024
62 198 689223413645
88 133 457404464825
19 57 803409835578
22 187 662331177910
18 31 529437059733
161 182 637731822589
109 131 32831735773
109 191 875742441191
43 78 135479410688
56 60 19000632823
44 143 6823771...

Bitaro to Manager

4
17135 3534 4830 14466
1
11921
2
17135 9906
4
17135 3534 18777 907
6
18033 13659 9145 14255 10379 11567
7
11921 7585 5782 2139 15549 19315 13987
2
17135 13815
5
17135 13815 8201 7265 15719
4
17135 3534 4830 9175
4
11921 7585 5782 8018
2
18033 13659
4
11921 7585 10922 14444
5
468 273 10532 11483 845...

Manager to Checker

0.99

result:

points 0.990

Test #2:

score: 100
Accepted
time: 1ms
memory: 4000kb

Manager to Aoi

6 7
0 5 839719370667
2 4 244076065937
1 5 337346113825
2 3 716558559511
1 4 837188452057
0 3 661778933008
1 3 678360389380
5
2 3 1 5 4
7
4 2 0 6 1 5 3

Aoi to Manager

A001001100010000101000100011100011000001000000110000110000000101000001011100F

Manager to Bitaro

6 7
0 5 -1
2 4 -1
1 5 -1
2 3 -1
1 4 -1
0 3 -1
1 3 -1
5
2 3 1 5 4
7
4 2 0 6 1 5 3
A001001100010000101000100011100011000001000000110000110000000101000001011100F

Bitaro to Manager

2
5 3
1
5
2
0 2
1
0
3
5 3 1
F

Manager to Checker

1.00

result:

points 1.0

Test #3:

score: 0
Instance #1 Time Limit Exceeded

Manager to Aoi

10000 19480
2933 9484 1000000000000
2567 9405 1000000000000
5263 6064 1000000000000
1453 8911 1000000000000
2445 8695 1000000000000
5686 7074 1000000000000
5031 5441 1000000000000
253 5144 1000000000000
8087 8704 1000000000000
263 3499 1000000000000
5200 8741 1000000000000
5764 8908 1000000000000
20...

Aoi to Manager

A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

Manager to Bitaro

10000 19480
2933 9484 1000000000000
2567 9405 1000000000000
5263 6064 1000000000000
1453 8911 1000000000000
2445 8695 1000000000000
5686 7074 1000000000000
5031 5441 1000000000000
253 5144 1000000000000
8087 8704 1000000000000
263 3499 1000000000000
5200 8741 1000000000000
5764 8908 1000000000000
20...

Bitaro to Manager


Manager to Checker

0.00

result: