Submission #719284

#TimeUsernameProblemLanguageResultExecution timeMemory
719284Joshi503Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h"
using namespace std;

using ll = long long;
#define int ll
using db = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
#define f first
#define s second

#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>;
tcT, size_t SZ > using AR = array<T, SZ>;
using vi = V<int>;
using vb = V<bool>;
using vl = V<ll>;
using vd = V<db>;
using vs = V<str>;
using vpi = V<pi>;
using vpl = V<pl>;

#define sz(x) ll((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sor(x) sort(all(x)) 
#define pb push_back
#define yes cout << "Y" << "e" << "s\n";
#define no cout << "N" << "o\n";

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = ((b)-1); i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rep(a) F0R(_,a)
#define each(a,x) for (auto& a: x)

const int MOD = 998244353;
const int MOD98 = 998244353;
const int MX = 1e9;
const int INF = 1e18;
const db PI = acos((db)-1);
/*



*/
int n, k;
vi d;
vector<vpi> adj;
int mini;
void dfs(int u, int p, int len = 1){
    each(v, adj[u]){
        if(v.f == p) continue;
        d[v.f] = d[u] + v.s;
        if(d[v.f] == k){
            mini = min(mini, len);
        }
        dfs(v.f, u, len + 1);
    }
}

int best_path(int N, int K, int H[][2], int L[]){
    adj = vector<vpi>(N + 1);
    n = N, k = K;
    F0R(i, N - 1){
        int u = H[i][0], v = H[i][1];
        adj[u].pb({v, L[i]});
        adj[v].pb({u, L[i]});
    }
    int ans = 1e18;
    F0R(i, N){
        mini = 1e18;
        d = vi(N + 1, 0LL);
        dfs(i, -1);
        ans = min(mini, ans);
    }
    return (ans == 1e18 ? -1 : ans);
}

Compilation message (stderr)

race.cpp:7:13: error: 'string' does not name a type
    7 | using str = string;
      |             ^~~~~~
race.cpp:8:12: error: 'pair' does not name a type
    8 | using pi = pair<int, int>;
      |            ^~~~
race.cpp:9:12: error: 'pair' does not name a type
    9 | using pl = pair<ll, ll>;
      |            ^~~~
race.cpp:10:12: error: 'pair' does not name a type
   10 | using pd = pair<db, db>;
      |            ^~~~
race.cpp:16:16: error: 'vector' does not name a type
   16 | tcT> using V = vector<T>;
      |                ^~~~~~
race.cpp:17:6: error: 'size_t' has not been declared
   17 | tcT, size_t SZ > using AR = array<T, SZ>;
      |      ^~~~~~
race.cpp:17:29: error: 'array' does not name a type
   17 | tcT, size_t SZ > using AR = array<T, SZ>;
      |                             ^~~~~
race.cpp:18:12: error: 'V' does not name a type
   18 | using vi = V<int>;
      |            ^
race.cpp:19:12: error: 'V' does not name a type
   19 | using vb = V<bool>;
      |            ^
race.cpp:20:12: error: 'V' does not name a type
   20 | using vl = V<ll>;
      |            ^
race.cpp:21:12: error: 'V' does not name a type
   21 | using vd = V<db>;
      |            ^
race.cpp:22:12: error: 'V' does not name a type
   22 | using vs = V<str>;
      |            ^
race.cpp:23:13: error: 'V' does not name a type
   23 | using vpi = V<pi>;
      |             ^
race.cpp:24:13: error: 'V' does not name a type
   24 | using vpl = V<pl>;
      |             ^
race.cpp:46:15: error: 'acos' was not declared in this scope
   46 | const db PI = acos((db)-1);
      |               ^~~~
race.cpp:53:1: error: 'vi' does not name a type
   53 | vi d;
      | ^~
race.cpp:54:1: error: 'vector' does not name a type
   54 | vector<vpi> adj;
      | ^~~~~~
race.cpp: In function 'void dfs(ll, ll, ll)':
race.cpp:57:13: error: 'adj' was not declared in this scope
   57 |     each(v, adj[u]){
      |             ^~~
race.cpp:40:33: note: in definition of macro 'each'
   40 | #define each(a,x) for (auto& a: x)
      |                                 ^
race.cpp:59:9: error: 'd' was not declared in this scope
   59 |         d[v.f] = d[u] + v.s;
      |         ^
race.cpp:61:20: error: 'min' was not declared in this scope; did you mean 'mini'?
   61 |             mini = min(mini, len);
      |                    ^~~
      |                    mini
race.cpp: In function 'll best_path(ll, ll, ll (*)[2], ll*)':
race.cpp:68:5: error: 'adj' was not declared in this scope
   68 |     adj = vector<vpi>(N + 1);
      |     ^~~
race.cpp:68:11: error: 'vector' was not declared in this scope
   68 |     adj = vector<vpi>(N + 1);
      |           ^~~~~~
race.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "race.h"
  +++ |+#include <vector>
    2 | using namespace std;
race.cpp:68:18: error: 'vpi' was not declared in this scope
   68 |     adj = vector<vpi>(N + 1);
      |                  ^~~
race.cpp:78:9: error: 'd' was not declared in this scope
   78 |         d = vi(N + 1, 0LL);
      |         ^
race.cpp:78:13: error: 'vi' was not declared in this scope; did you mean 'i'?
   78 |         d = vi(N + 1, 0LL);
      |             ^~
      |             i
race.cpp:80:15: error: 'min' was not declared in this scope; did you mean 'mini'?
   80 |         ans = min(mini, ans);
      |               ^~~
      |               mini