QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#292335#7118. Closing TimeFeet_McYeet0 115ms30584kbC++172.2kb2023-12-28 01:14:232024-04-28 08:01:50

Judging History

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

  • [2024-04-28 08:01:50]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:115ms
  • 内存:30584kb
  • [2023-12-28 01:14:23]
  • 评测
  • 测评结果:0
  • 用时:96ms
  • 内存:31580kb
  • [2023-12-28 01:14:23]
  • 提交

answer

// #include "closing.h"
#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("avx2")
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define el << '\n'
#define nl cout << '\n'
#define spc << ' '
#define forn(i,n) for (int i=0; i<n; i++)
#define forl(i,s,e) for (int i=s; i<e; i++)
#define pb push_back
#define fi first
#define se second
#define rsz resize
#define sz(x) ((int) x.size())
#define all(x) x.begin(), x.end()

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
	vector<pll> dis(N);
	vector<vector<pll>> adj(N);
	struct st {
		int cn, pn; ll d; bool p;
	};
	forn(i,N-1) {
		adj[U[i]].pb({V[i], W[i]});
		adj[V[i]].pb({U[i], W[i]});
	}
	vector<st> stk;
	stk.pb({X, -1, 0, 0});
	while (sz(stk)) {
		st a = stk.back();
		stk.pop_back();
		if (a.p) dis[a.cn].se = a.d;
		else dis[a.cn].fi = a.d;
		for (pii i : adj[a.cn]) if (i.fi != a.pn) stk.pb({i.fi, a.cn, a.d+i.se, a.p});
	}
	stk.pb({Y, -1, 0, 1});
	while (sz(stk)) {
		st a = stk.back();
		stk.pop_back();
		if (a.p) dis[a.cn].se = a.d;
		else dis[a.cn].fi = a.d;
		for (pii i : adj[a.cn]) if (i.fi != a.pn) stk.pb({i.fi, a.cn, a.d+i.se, a.p});
	}
	forn(i,N) if (dis[i].fi < dis[i].se) swap(dis[i].fi, dis[i].se);
	forn(i,N) dis[i].fi -= dis[i].se;
	sort(all(dis));
	vector<bool> u(N);
	forn(i,N) u[i] = false;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
	priority_queue<pair<ll, int>> rpq;
	forn(i,N) cout << dis[i].fi spc << dis[i].se el;
	nl;
	forn(i,N) pq.push({dis[i].se, i});
	int tot = 0;
	while (1) {
		ll temp = K - pq.top().fi;
		if (temp < 0) break;
		u[pq.top().se] = 1;
		rpq.push(pq.top());
		pq.pop();
		K = temp;
		tot++;
	}
	// cout << K spc << tot el;
	int ans = tot;
	forn(i,N) {
		if (u[i]) {
			K += dis[i].se;
			tot--;
		}
		K -= dis[i].fi + dis[i].se;
		tot += 2;
		bool temp = false;
		while (K<0) {
			if (!sz(rpq)) {
				temp = true;
				break;
			}
			auto cn = rpq.top();
			rpq.pop();
			if (cn.se <= i) continue;
			tot--;
			K += cn.fi;
		}
		if (temp) break;
		ans = max(ans, tot);
		// cout << K spc << tot el;
	}
	return ans;	
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 115ms
memory: 30584kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
200000 31011 61157 8517583098
31011 129396 964383
1655 129396 331139
1655 191487 566483
110385 191487 865248
43212 110385 542661
43212 81682 13766
81682 91774 546589
91774 124706 780638
124706 175650 118706
10421 175650 615314
10421 151953 436270
140430 151...

output:

656316 17112669535
656316 17112670027
656316 17112670292
726052 17112634667
726052 17112635305
726052 17112635525
726052 17112635637
726052 17112636630
1806216 17112094585
2272508 17111861439
2272508 17111861740
2272508 17111862326
2967022 17111514182
2967022 17111514587
2967022 17111514807
3317576 ...

result:

wrong answer secret mismatch

Subtask #2:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 4108kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
50 23 25 382806473
0 1 375710
1 2 898637
2 3 10402
3 4 536577
4 5 385023
5 6 71075
6 7 543368
7 8 301497
8 9 174394
9 10 711312
10 11 923006
11 12 675532
12 13 838667
13 14 565729
14 15 979816
15 16 862618
16 17 576015
17 18 177751
18 19 306989
19 20 881492...

output:

56234 794706
1645646 0
1645646 0
1645646 710571
1645646 749430
1645646 1408345
1645646 1569247
1645646 1601240
1645646 2450739
1645646 2505087
1645646 2757728
1645646 2935479
1645646 3073462
1645646 3144441
1645646 3511494
1645646 4051192
1645646 4374112
1645646 4470902
1645646 4483983
1645646 52407...

result:

wrong answer secret mismatch

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 0ms
memory: 4104kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
4 0 1 9
0 2 2
1 2 3
2 3 3

output:

1 2
1 5
5 0
5 0

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
6

result:

wrong answer secret mismatch

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #4:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

0%