답안 #947654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947654 2024-03-16T17:51:32 Z yeediot 공장들 (JOI14_factories) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "factories.n"
using namespace std;
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pb push_back
#define sz(x) (int)(x.size())
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define vi vector<int>
#define vp vector<pii>
#define vvi vector<vi>
#define ykh mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count())
#define __lg(x) 63-__builtin_clzll(x)
#define pow2(x) (1LL<<x)
void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
#ifdef local
void setio(){freopen("/Users/iantsai/Library/Mobile Documents/com~apple~CloudDocs/cpp/Empty.md","r",stdin);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
void setio(){}
#define debug(x...)
#endif
const int mxn=5e5+5;
vector<pii>adj[mxn];
int cnt[mxn];
bool vis[mxn];
vector<pair<int,long long>>p[mxn];
pair<long long,long long> mn[mxn];
void cnt_sz(int v,int pa){
    cnt[v]=1;
    for(auto [u,d]:adj[v]){
        if(vis[u] or u==pa)continue;
        cnt_sz(u,v);
        cnt[v]+=cnt[u];
    }
}
int find_cen(int v,int pa,int tar){
    for(auto [u,d]:adj[v]){
        if(vis[u] or u==pa)continue;
        if(cnt[u]*2>tar)return find_cen(u,v,tar);
    }
    return v;
}
void dfs(int v,int pa,int top,int cur){
    p[v].pb({top,cur});
    for(auto [u,d]:adj[v]){
        if(vis[u] or u==pa)continue;
        dfs(u,v,top,cur+d);
    }
}
void cen(int v){
    cnt_sz(v,v);
    v=find_cen(v,v,cnt[v]);
    vis[v]=1;
    dfs(v,v,v,0);
    for(auto [u,d]:adj[v]){
        if(vis[u])continue;
        cen(u);
    }
}
void Init(int N,int A[],int B[],int D[]){
    for(int i=0;i<N-1;i++){
        adj[A[i]].pb({B[i],D[i]});
        adj[B[i]].pb({A[i],D[i]});
    }
    cen(1);
}
long long Query(int S,int X[],int T,int Y[]){
    for(int i=0;i<S;i++){
        for(auto [u,l]:p[X[i]]){
            mn[u]={1e18,1e18};
        }
    }
    for(int i=0;i<T;i++){
        for(auto [u,l]:p[Y[i]]){
            mn[u]={1e18,1e18};
        }
    }
    long long ans=1e18;
    for(int i=0;i<S;i++){
        for(auto [u,l]:p[X[i]]){
            chmin(mn[u].F,l);
        }
    }
    for(int i=0;i<T;i++){
        for(auto [u,l]:p[Y[i]]){
            chmin(mn[u].S,l);
            chmin(ans,mn[u].F+mn[u].S);
        }
    }
    for(int i=0;i<S;i++){
        for(auto [u,l]:p[X[i]]){
            chmin(ans,mn[u].F+mn[u].S);
        }
    }
    return ans;
}
 /*
 input:
 
 */















 

Compilation message

factories.cpp:2:10: fatal error: factories.n: No such file or directory
    2 | #include "factories.n"
      |          ^~~~~~~~~~~~~
compilation terminated.