Submission #987704

# Submission time Handle Problem Language Result Execution time Memory
987704 2024-05-23T11:40:07 Z Tsagana Race (IOI11_race) C++14
Compilation error
0 ms 0 KB
#include "race.h"

#include<bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define F first
#define S second

using namespace std;

int d, dsu[200069], cc[200069], lz[200069][2], z, inf=2e9;
vector  <pair<int, int>> adj[200069];
multiset<pair<int, int>>  ms[200069];
 
int fd(int x) {
  if (dsu[x] == x) return x;
  return dsu[x] = fd(dsu[x]);
}
 
void jo(int x,int y) {
  int k, w; x = fd(x); y = fd(y);
  if (cc[x] < cc[y]) swap(x, y);
  
  for (auto it: ms[y]) {
    k = it->F + lz[y][1];
    w = it->S + lz[y][0];
    auto it2 = ms[x].lb({d - k - lz[x][1], -inf});
    if (it2 != ms[x].end() && it2->F + lz[x][1] == d - k)
    z = min(z, w + it2->S + lz[x][0]);
  }
  for (auto it: ms[y]) {
    k = it->F + lz[y][1];
    w = it->S + lz[y][0];
    ms[x].insert({k - lz[x][1], w - lz[x][0]});
  }
  dsu[y] = x; cc[x] += cc[y];
}
 
void dfs(int x) {
  vtd[x] = cc[x] = 1; dsu[x] = x;
  ms[x].insert({0, 0});
  for (auto i: adj[x]) {
    int l = i.F, w = i.S;
    if (!vtd[l]) {
      dfs(l);
      lz[fd(l)][0]++;
      lz[fd(l)][1] += w;
      jo(x,l);
    }
  }
}
 
int best_path(int n,int od,int ed[][2],int wg[]) {
  int k, l;
  d = od;
  for (int i = 0; i < n-1; i++) {
    k = ed[i][0];
    l = ed[i][1];
    adj[k].pb({l, wg[i]});
    adj[l].pb({k, wg[i]});
  }
  z = inf;
  dfs(0);
  if (z == inf) z = -1;
  return z;
}

Compilation message

race.cpp: In function 'void jo(int, int)':
race.cpp:30:11: error: base operand of '->' has non-pointer type 'std::pair<int, int>'
   30 |     k = it->F + lz[y][1];
      |           ^~
race.cpp:31:11: error: base operand of '->' has non-pointer type 'std::pair<int, int>'
   31 |     w = it->S + lz[y][0];
      |           ^~
race.cpp:37:11: error: base operand of '->' has non-pointer type 'std::pair<int, int>'
   37 |     k = it->F + lz[y][1];
      |           ^~
race.cpp:38:11: error: base operand of '->' has non-pointer type 'std::pair<int, int>'
   38 |     w = it->S + lz[y][0];
      |           ^~
race.cpp: In function 'void dfs(int)':
race.cpp:45:3: error: 'vtd' was not declared in this scope; did you mean 'std'?
   45 |   vtd[x] = cc[x] = 1; dsu[x] = x;
      |   ^~~
      |   std