답안 #1070148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070148 2024-08-22T11:54:50 Z TsotneSV 경주 (Race) (IOI11_race) C++14
컴파일 오류
0 ms 0 KB
#pragma gcc diagnostic "-std=c++1z"
#include <bits/stdc++.h>
#include "race.h"
using namespace std;
/* /\_/\
  (= ._.)
  / >  \>
*/
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // codeforces

 #define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define mp make_pair
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(0);}
#define endl '\n'
#define sz(x) ((long long) (x).size())
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<" ";
#define printl(x) cout<<(x)<<endl
#define dbg(x) cerr<<#x<<" "<<x<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;


const int inf=1e9,MAXN=2e5+5; 

vpi g[MAXN]; set<pair<ll,int>> st[MAXN];
int ans;

void dfs(int v,int p,int d,int k,ll curr = 0) {

    for(auto [u,w] : g[v]) {

        if(u == p) continue;

        dfs(u,v,d+1,k,curr+w);

        if(st[v].size() < st[u].size()) swap(st[u],st[v]);

        for(auto x : st[u]) st[v].ins(x);
    }

    st[v].ins({curr,d});

    auto x = st[v].lower_bound({curr+k,0});

    if(x != st[v].end() and (*x).fi == curr+k) ans = min(ans,(*x).se - d);
}

int best_path(int N, int K, int H[][2], int L[]) {

    ans = inf; 

    for(int i=0;i<N;i++) g[i].clear(),st[i].clear();

    for(int i=0;i<N-1;i++) {
        g[H[i][0]].pb({H[i][1],L[i]});
        g[H[i][1]].pb({H[i][0],L[i]});
    }

    dfs(0,-1,0,K);
    
    return (ans == inf ? -1 : ans);

}

/* int main() {

    send help

    int H[][2] = { {0,1}, {0,2}, {2,3}, {3,4}, {4,5}, {0,6}, {6,7}, {6,8}, {8,9}, {8,10} };
    int L[] = {3,4,5,4,6,3,2,5,6,7};

    printl(best_path(11,12,H,L));

    return 0;

} */

Compilation message

race.cpp:1: warning: ignoring '#pragma gcc diagnostic' [-Wunknown-pragmas]
    1 | #pragma gcc diagnostic "-std=c++1z"
      | 
race.cpp: In function 'void dfs(long long int, long long int, long long int, long long int, ll)':
race.cpp:47:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |     for(auto [u,w] : g[v]) {
      |              ^
/usr/bin/ld: /tmp/cczK8ghd.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status