QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#291894 | #7118. Closing Time | Goldenglow1427 | Compile Error | / | / | C++14 | 2.4kb | 2023-12-27 12:52:43 | 2024-04-28 07:59:47 |
Judging History
你现在查看的是最新测评结果
- [2024-04-28 07:59:47]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-27 12:52:44]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-27 12:52:43]
- 提交
answer
/*
ID: Victor Chen [mail_vi1]
PROG: Closing Time
LANG: C++
*/
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int Maxn = 2e5;
class Graph
{
public:
int cnt, head[Maxn+10];
struct Edge
{
int to, nxt;
int val;
}p[2*Maxn+10];
int root;
int dep[Maxn+10], fa[Maxn+10];
ll val[Maxn+10];
void AddEdge(int x, int y, int v)
{
cnt++;
p[cnt].to = y;
p[cnt].val = v;
p[cnt].nxt = head[x];
head[x] = cnt;
}
void dfs(int x)
{
for(int i=head[x]; i!=0; i=p[i].nxt)
if(dep[p[i].to] == 0)
{
dep[p[i].to] = dep[x] + 1;
fa[p[i].to] = x;
val[p[i].to] = val[x] + p[i].val;
dfs(p[i].to);
}
}
void clear()
{
cnt = 0;
memset(head, 0, sizeof(head));
}
void init(int x)
{
root = x;
memset(dep, 0, sizeof(dep));
dep[root] = 1;
fa[root] = 0;
val[root] = 0;
dfs(root);
}
}g;
int n;
int c1, c2;
ll cst;
ll val[Maxn+10];
struct Pair
{
int id;
ll dis;
Pair(){}
Pair(int id, ll dis)
{
this->id = id;
this->dis = dis;
}
bool operator < (const Pair &x) const
{
return x.dis < dis;
}
};
priority_queue<Pair> q;
int max_score(int N, int X, int Y, ll K, int U[], int V[], int W[])
{
int ans = 0;
memset(val, INF, sizeof(val));
g.clear();
n = N, c1 = X, c2 = Y;
for(int i=0; i<n-1; i++)
{
g.AddEdge(U[i], V[i], W[i]);
g.AddEdge(V[i], U[i], W[i]);
}
// Case 1: If only consider without connections.
g.init(c1);
for(int i=1; i<=n; i++)
val[i] = min(val[i], g.val[i]);
g.init(c2);
for(int i=1; i<=n; i++)
val[i] = min(val[i], g.val[i]);
cst = 0;
sort(val+1, val+n+1);
for(int i=1; i<=n; i++)
if(cst + val[i] <= K)
cst += val[i], ans++;
else
break;
return ans;
}
Details
/usr/bin/ld: /tmp/ccjY1WcW.o: in function `main': implementer.cpp:(.text.startup+0x744): undefined reference to `max_score(int, int, int, long long, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)' collect2: error: ld returned 1 exit status