Submission #994007

# Submission time Handle Problem Language Result Execution time Memory
994007 2024-06-07T01:44:49 Z aaaaaarroz Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<pair<ll,ll>>>graph;
vector<bool> vis;
void dfs1(vector<ll> &dist, ll x, ll d){
    vis[x] = true;
    dist[x] = d;
    for (auto [y, w] : graph[x]){
        if (!vis[y]){
            dfs1(dist, y, d + w);
        }
    }
}
void dfs2(vector<pair<ll,ll>>dist, ll x, ll d){
    vis[x] = true;
    dist[x].first= d;
    for (auto [y, w] : graph[x]){
        if (!vis[y]){
            dfs2(dist, y, d + w);
        }
    }
}
ll max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W){
	graph.assign(N,vector<pair<ll,ll>>());
	for(ll i=0;i<(N-1);i++){
		graph[U[i]].push_back({V[i],W[i]});
		graph[V[i]].push_back({U[i],W[i]});
	}
	vis.assign(N,false);
	vector<ll>distX(N);
	dfs1(distX,X,0);
	vis.assign(N,false);
	vector<ll>distY(N);
	dfs1(distY,Y,0);
	vis.assign(N,false);
	vector<pair<ll,ll>>orden;
	for(ll i=0;i<N;i++){c
		pair<ll,ll>par;
		par.first=0;
		par.second=i;
		orden.push_back(par);
	}
	dfs2(orden,max_element(distX.begin(),distX.end())-distX.begin(),0);
	sort(orden.begin(),orden.end());
	ll pos_x;
	ll pos_y;
	for(ll i=0;i<N;i++){
		if(orden[i].second==X){
			pos_x=i;
		}
		else if(orden[i].second==Y){
			pos_y=i;
		}
	}
	pos_x++;
	pos_y++;
	vector<ll>prefix1(N+1,0);
	for(ll i=0;i<N;i++){
		prefix1[i+1]=prefix1[i]+distX[orden[i].second];
	}
	vector<ll>prefix2(N+1,0);
	for(ll i=0;i<N;i++){
		prefix2[i+1]=prefix2[i]+distY[orden[i].second];
	}
	ll ans=0;
	for(ll i=0;i<pos_x;i++){
		for(ll j=pos_x;j<=N;j++){
			for(ll k=0;k<pos_y;k++){
				for(ll l=pos_y;l<=N;l++){
					if((prefix1[j]-prefix1[i]+prefix2[l]-prefix2[k])<=K){
						ans=max((j-i+l-k),ans);
					}
				}
			}
		}
	}
	return ans;
}

Compilation message

closing.cpp: In function 'll max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:38:22: error: 'c' was not declared in this scope
   38 |  for(ll i=0;i<N;i++){c
      |                      ^
closing.cpp:40:3: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   40 |   par.first=0;
      |   ^~~
      |   __pstl::execution::v1::par
In file included from /usr/include/c++/10/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:1:
/usr/include/c++/10/pstl/execution_defs.h:111:27: note: '__pstl::execution::v1::par' declared here
  111 | constexpr parallel_policy par{};
      |                           ^~~