Submission #660250

# Submission time Handle Problem Language Result Execution time Memory
660250 2022-11-21T10:19:01 Z MilosMilutinovic Amusement Park (JOI17_amusement_park) C++14
Compilation error
0 ms 0 KB
#include "Joi.h"#include <bits/stdc++.h> using namespace std; void Joi(int n, int m, int u[], int v[], long long x, int t) {  vector<vector<int>> e(n);  for (int i = 0; i < m; i++) {    e[u[i]].push_back(v[i]);    e[v[i]].push_back(u[i]);  }  for (int i = 0; i < n; i++) {    sort(e[i].begin(), e[i].end());  }  vector<vector<int>> g(n);  vector<bool> was(n);  function<void(int, int)> MakeTree = [&](int v, int pv) {    was[v] = true;    for (int u : e[v]) {      if (was[u]) {        continue;      }      g[v].push_back(u);      g[u].push_back(v);      MakeTree(u, v);    }  };  MakeTree(0, 0);  const int L = 20;  vector<vector<int>> pr(n, vector<int>(L));  vector<int> dep(n);  function<void(int, int)> Dfs = [&](int v, int pv) {    pr[v][0] = pv;    for (int j = 1; j < L; j++) {      pr[v][j] = pr[pr[v][j - 1]][j - 1];    }    for (int u : g[v]) {      if (u == pv) {        continue;      }      dep[u] = dep[v] + 1;      Dfs(u, v);    }  };  Dfs(0, 0);  auto LCA = [&](int x, int y) {    if (dep[x] < dep[y]) {      swap(x, y);    }    for (int i = L - 1; i >= 0; i--) {      if (dep[pr[x][i]] >= dep[y]) {        x = pr[x][i];      }    }    if (x == y) {      return x;    }    for (int i = L - 1; i >= 0; i--) {      if (pr[x][i] != pr[y][i]) {        x = pr[x][i];        y = pr[y][i];      }    }    return pr[x][0];  };  auto GetDist = [&](int x, int y) {    return dep[x] + dep[y] - 2 * dep[LCA(x, y)];  };  vector<int> ver;  function<void(int, int)> Go = [&](int v, int pv) {    if (ver.size() == 60) {      return;    }    ver.push_back(v);    for (int u : g[v]) {      if (u == pv) {        continue;      }      Go(u, v);    }  };  Go(0, 0);  vector<vector<int>> ids(n);  for (int x : ver) {    ids[x] = ver;  }  vector<int> ans(n);  for (int i = 0; i < 60; i++) {    ans[ver[i]] = (x >> i & 1);  }  function<void(int, int)> Solve = [&](int v, int pv) {    if (ids[v].empty()) {      ids[v] = ids[pv];      int idx = 0;      for (int i = 1; i < 60; i++) {        if (GetDist(ids[v][i], v) > GetDist(ids[v][idx], v)) {          idx = i;        }      }      ans[v] = ans[ids[v][idx]];      ids[v][idx] = v;    }    for (int u : g[v]) {      if (u == pv) {        continue;      }      Solve(u, v);    }  };  Solve(0, 0);  for (int i = 0; i < n; i++) {    MessageBoard(i, ans[i]);  }}
#include "Ioi.h"
#include <bits/stdc++.h>
 
using namespace std;
 
long long Ioi(int n, int m, int u[], int v[], int p, int me, int t) {
  vector<vector<int>> e(n);
  for (int i = 0; i < m; i++) {
    e[u[i]].push_back(v[i]);
    e[v[i]].push_back(u[i]);
  }
  for (int i = 0; i < n; i++) {
    sort(e[i].begin(), e[i].end());
  }
  vector<vector<int>> g(n);
  vector<bool> was(n);
  function<void(int, int)> MakeTree = [&](int v, int pv) {
    was[v] = true;
    for (int u : e[v]) {
      if (was[u]) {
        continue;
      }
      g[v].push_back(u);
      g[u].push_back(v);
      MakeTree(u, v);
    }
  };
  MakeTree(0, 0);
  const int L = 20;
  vector<vector<int>> pr(n, vector<int>(L));
  vector<int> dep(n);
  function<void(int, int)> Dfs = [&](int v, int pv) {
    pr[v][0] = pv;
    for (int j = 1; j < L; j++) {
      pr[v][j] = pr[pr[v][j - 1]][j - 1];
    }
    for (int u : g[v]) {
      if (u == pv) {
        continue;
      }
      dep[u] = dep[v] + 1;
      Dfs(u, v);
    }
  };
  Dfs(0, 0);
  auto LCA = [&](int x, int y) {
    if (dep[x] < dep[y]) {
      swap(x, y);
    }
    for (int i = L - 1; i >= 0; i--) {
      if (dep[pr[x][i]] >= dep[y]) {
        x = pr[x][i];
      }
    }
    if (x == y) {
      return x;
    }
    for (int i = L - 1; i >= 0; i--) {
      if (pr[x][i] != pr[y][i]) {
        x = pr[x][i];
        y = pr[y][i];
      }
    }
    return pr[x][0];
  };
  auto GetDist = [&](int x, int y) {
    return dep[x] + dep[y] - 2 * dep[LCA(x, y)];
  };
  vector<int> ver;
  function<void(int, int)> Go = [&](int v, int pv) {
    if (ver.size() == 60) {
      return;
    }
    ver.push_back(v);
    for (int u : g[v]) {
      if (u == pv) {
        continue;
      }
      Go(u, v);
    }
  };
  Go(0, 0);
  vector<vector<int>> ids(n);
  for (int x : ver) {
    ids[x] = ver;
  }
  function<void(int, int)> Solve = [&](int v, int pv) {
    if (ids[v].empty()) {
      ids[v] = ids[pv];
      int idx = 0;
      for (int i = 1; i < 60; i++) {
        if (GetDist(ids[v][i], v) > GetDist(ids[v][idx], v)) {
          idx = i;
        }
      }
      ids[v][idx] = v;
    }
    for (int u : g[v]) {
      if (u == pv) {
        continue;
      }
      Solve(u, v);
    }
  };
  Solve(0, 0);
  vector<int> bit(n, -1);
  for (int i = 0; i < 60; i++) {
    bit[ids[p][i]] = i;
  }
  vector<int> f(n);
  f[p] = me;
  function<void(int, int)> FindBits = [&](int v, int pv) {
    for (int u : g[v]) {
      if (bit[u] == -1 || u == pv) {
        continue;
      }
      f[u] = Move(u);
      FindBits(u, v);
      f[v] = Move(v);
    }
  };
  FindBits(p, p);
  long long res = 0;
  for (int i = 0; i < n; i++) {
    if (bit[i] != -1) {
      res += (1LL << bit[i]) * f[i];
    }
  }
  return res;
}

Compilation message

Joi.cpp:1:17: warning: extra tokens at end of #include directive
    1 | #include "Joi.h"#include <bits/stdc++.h> using namespace std; void Joi(int n, int m, int u[], int v[], long long x, int t) {  vector<vector<int>> e(n);  for (int i = 0; i < m; i++) {    e[u[i]].push_back(v[i]);    e[v[i]].push_back(u[i]);  }  for (int i = 0; i < n; i++) {    sort(e[i].begin(), e[i].end());  }  vector<vector<int>> g(n);  vector<bool> was(n);  function<void(int, int)> MakeTree = [&](int v, int pv) {    was[v] = true;    for (int u : e[v]) {      if (was[u]) {        continue;      }      g[v].push_back(u);      g[u].push_back(v);      MakeTree(u, v);    }  };  MakeTree(0, 0);  const int L = 20;  vector<vector<int>> pr(n, vector<int>(L));  vector<int> dep(n);  function<void(int, int)> Dfs = [&](int v, int pv) {    pr[v][0] = pv;    for (int j = 1; j < L; j++) {      pr[v][j] = pr[pr[v][j - 1]][j - 1];    }    for (int u : g[v]) {      if (u == pv) {        continue;      }      dep[u] = dep[v] + 1;      Dfs(u, v);    }  };  Dfs(0, 0);  auto LCA = [&](int x, int y) {    if (dep[x] < dep[y]) {      swap(x, y);    }    for (int i = L - 1; i >= 0; i--) {      if (dep[pr[x][i]] >= dep[y]) {        x = pr[x][i];      }    }    if (x == y) {      return x;    }    for (int i = L - 1; i >= 0; i--) {      if (pr[x][i] != pr[y][i]) {        x = pr[x][i];        y = pr[y][i];      }    }    return pr[x][0];  };  auto GetDist = [&](int x, int y) {    return dep[x] + dep[y] - 2 * dep[LCA(x, y)];  };  vector<int> ver;  function<void(int, int)> Go = [&](int v, int pv) {    if (ver.size() == 60) {      return;    }    ver.push_back(v);    for (int u : g[v]) {      if (u == pv) {        continue;      }      Go(u, v);    }  };  Go(0, 0);  vector<vector<int>> ids(n);  for (int x : ver) {    ids[x] = ver;  }  vector<int> ans(n);  for (int i = 0; i < 60; i++) {    ans[ver[i]] = (x >> i & 1);  }  function<void(int, int)> Solve = [&](int v, int pv) {    if (ids[v].empty()) {      ids[v] = ids[pv];      int idx = 0;      for (int i = 1; i < 60; i++) {        if (GetDist(ids[v][i], v) > GetDist(ids[v][idx], v)) {          idx = i;        }      }      ans[v] = ans[ids[v][idx]];      ids[v][idx] = v;    }    for (int u : g[v]) {      if (u == pv) {        continue;      }      Solve(u, v);    }  };  Solve(0, 0);  for (int i = 0; i < n; i++) {    MessageBoard(i, ans[i]);  }}
      |                 ^
/usr/bin/ld: /tmp/cc6tyAJx.o: in function `main':
grader_joi.cpp:(.text.startup+0x1ae): undefined reference to `Joi(int, int, int*, int*, long long, int)'
collect2: error: ld returned 1 exit status

Ioi.cpp:114:2: error: extended character   is not valid in an identifier
  114 |       if (bit[u] == -1 || u == pv) {
      |  ^
Ioi.cpp:114:5: error: extended character   is not valid in an identifier
  114 |       if (bit[u] == -1 || u == pv) {
      |    ^
Ioi.cpp:114:8: error: extended character   is not valid in an identifier
  114 |       if (bit[u] == -1 || u == pv) {
      |      ^
Ioi.cpp: In lambda function:
Ioi.cpp:114:2: error: '\U000000a0' was not declared in this scope
  114 |       if (bit[u] == -1 || u == pv) {
      |  ^