# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
969284 | angels | Closing Time (IOI23_closing) | C++17 | 1043 ms | 21336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
int n=N, x=X, y=Y;
long long k=K;
vector<pair<int, int>>a[n];
for(int i=0; i<n-1; i++)
{
a[U[i]].push_back({V[i], W[i]});
a[V[i]].push_back({U[i], W[i]});
}
int rez=0;
int visited[n];
memset(visited, 0, sizeof(visited));
int id=1;
for(int i=0; i<n; i++)
{
queue<pair<int, long long>>q;
q.push(make_pair(i, 0));
while(!q.empty())
{
pair<int, long long>ww=q.front();
q.pop();
visited[ww.first]=id;
if((ww.first==x || ww.first==y) && ww.second<=k)
{
rez++;
break;
}
if(ww.second>k)
continue;
for(int i=0; i<a[ww.first].size(); i++)
{
if(visited[a[ww.first][i].first]!=id)
{
q.push(make_pair(a[ww.first][i].first, ww.second+a[ww.first][i].second));
}
}
}
id++;
}
return rez;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |