QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#217317#7118. Closing Timehocky#0 0ms0kbC++142.8kb2023-10-16 19:03:222024-04-28 07:53:09

Judging History

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

  • [2024-04-28 07:53:09]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-10-16 19:03:22]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-10-16 19:03:22]
  • 提交

answer

#include "closing.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i = a;i < b;i++)
#define trav(nx, v) for(auto &nx : v)
#define all(a) begin(a), end(a)
#define sz(v) (int) v.size()

int n;
typedef array<LL, 4> CostNodeFrom;
CostNodeFrom plain = {-1,-1,-1,-1};
multiset<CostNodeFrom> prim;
const int LIM = 200000;
vector <PLL> edge[LIM + 5];
set <int> isInside[LIM + 5];
LL curans[LIM + 5];
CostNodeFrom cheap[LIM + 5][2];
ostream& operator<<(ostream &os, CostNodeFrom c) {
	os <<"(" << c[0] << ", " << c[1] << ", " << c[2] << ", " << c[3] <<")";
	return os;
}
 

void updateCheap(int node, LL val, bool isX) {
	//~ cout << "Updating " << endl;
	cheap[node][isX] = plain;
	if(cheap[node][!isX][1] != -1) {
		prim.erase(prim.find(cheap[node][!isX]));
		curans[node] += val;
		cheap[node][!isX][0] = max(0LL, cheap[node][!isX][3] - curans[node]);
		//~ assert(oldCost - curans[node] >= 0);
		//~ cout << cheap[node][!isX] << endl;
		prim.insert(cheap[node][!isX]);
	} else {
		curans[node] += val;
	}
}

int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W){
	n = N;
	rep(i,0,N) {
		edge[i].clear();
		isInside[i].clear();
		curans[i] = 0;
		cheap[i][0] = cheap[i][1] = plain;
	}
	//~ cout << "Here " << U[0] << " " << V[0] << ""  << W[0] << endl;
	prim.clear();
	rep(i,0,N - 1){
		if(W[i] > K) continue;
		//~ cout << U[i] << " " << V[i] << endl;
		edge[U[i]].emplace_back(V[i], W[i]);
		edge[V[i]].emplace_back(U[i], W[i]);
		
	}
	isInside[X].insert(X);
	isInside[Y].insert(Y);
	LL ans = 2;
	trav(tmp, edge[X]){
		CostNodeFrom nx = {tmp.se, tmp.fi, X, tmp.se};
		prim.insert(nx);
		cheap[tmp.fi][1] = nx;
	}
	trav(tmp, edge[Y]) {
		CostNodeFrom nx = {tmp.se, tmp.fi, Y, tmp.se};
		prim.insert(nx);
		cheap[tmp.fi][0] = nx;
	}
	while(sz(prim)){
		auto currentTop = *prim.begin();
		//~ cout << "here K = " << K << " relaxing node " << currentTop[1] << " with cost " << currentTop[0] << " from node " << currentTop[2] << endl;
		prim.erase(prim.begin());
		if(K < currentTop[0]) break;
		updateCheap(currentTop[1], currentTop[0], currentTop[2] == X);
		trav(cur, edge[currentTop[1]]){
			if(isInside[cur.fi].count(currentTop[2])) continue;
			auto addCost = max(currentTop[3] + cur.se - curans[cur.fi], 0LL);
			CostNodeFrom nxCheap = {addCost, cur.fi, currentTop[2], currentTop[3] + cur.se};
			cheap[cur.fi][currentTop[2]] = nxCheap;
			prim.insert(nxCheap);
		}
		K -= currentTop[0];
		ans++;
		isInside[currentTop[1]].insert(currentTop[2]);
	}
	//~ rep(i,0,n){
		//~ cout << curans[i] << " ";
	//~ }
	//~ cout << endl;
    return ans;
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

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:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
451

result:


Subtask #2:

score: 0
Runtime Error

Test #4:

score: 0
Runtime Error

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:


result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Runtime Error

Test #36:

score: 0
Runtime Error

input:

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

output:


result:


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%