답안 #500064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500064 2021-12-30T09:58:44 Z 600Mihnea Amusement Park (JOI17_amusement_park) C++17
컴파일 오류
0 ms 0 KB
#include "Joi.h"
#include <bits/stdc++.h>

using namespace std;

const int BITS = 60;

mt19937 reng(777777);


void Joi(int N, int M, int A[], int B[], long long X, int T) {
  int root = reng() % N;
  vector<vector<int>> g(N);
  vector<int> color(N, -1);

  for (int i = 0; i < M; i++) {
    g[A[i]].push_back(B[i]);
    g[B[i]].push_back(A[i]);
  }


  vector<bool> vis(N, 0);
  vector<vector<int>> ng(N);

  function<void(int)> makeG = [&] (int a) {
    vis[a] = 1;
    for (auto &b : g[a]) {
      if (!vis[b]) {
        ng[a].push_back(b);
        makeG(b);
      }
    }
  };
  makeG(root);
  g = ng;


  function<void(int)> draw = [&] (int a) {
    vector<int> all;
    queue<int> q;
    q.push(a);
    all.push_back(a);
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (auto &y : g[x]) {
        if ((int) all.size() + 1 > BITS) break;
        q.push(y);
        all.push_back(y);
      }
    }
    assert((int) all.size() <= BITS);
    for (int i = 0; i < (int) all.size(); i++) {
      color[all[i]] = i;
    }
    for (int i = 0; i < (int) all.size(); i++) {
      for (auto &v : g[all[i]]) {
        if (color[v] == -1) {
          draw(v);
        }
      }
    }
  };
  draw(root);
  for (auto &x : color) assert(0 <= x && x < BITS);


  vector<int> numBits(BITS);
  for (int i = 0; i < BITS; i++) {
    if (X & (1LL << i)) {
      numBits[i] = 1;
    } else {
      numBits[i] = 0;
    }
  }



  for(int i = 0; i < N; i++) {
    MessageBoard(i, numBits[color[i]]);
  }
}


#include "Ioi.h"

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int BITS = 60;
mt19937 rng(777777);

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  int root = rng() % N;
  vector<vector<int>> g(N);
  vector<int> color(N, -1);
  vector<int> parrent(N, -1);

  for (int i = 0; i < M; i++) {
    g[A[i]].push_back(B[i]);
    g[B[i]].push_back(A[i]);
  }

  vector<bool> vis(N, 0);
  vector<int> sub(N);
  vector<vector<int>> ng(N);

  function<void(int)> makeG = [&] (int a) {
    vis[a] = 1;
    sub[a] = 1;
    for (auto &b : g[a]) {
      if (!vis[b]) {
        ng[a].push_back(b);
        makeG(b);
        parrent[b] = a;
        sub[a] += sub[b];
      }
    }
  };
  makeG(root);
  g = ng;

  map<int, vector<pair<int, int>>> guys;
  vector<int> who(N);

  function<void(int)> draw = [&] (int a) {
    vector<pair<int, int>> all;
    queue<int> q;
    q.push(a);
    vector<int> vrts = {a};
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (auto &y : g[x]) {
        if ((int) vrts.size() + 1 > BITS) break;
        q.push(y);
        vrts.push_back(y);
        all.push_back({x, y});
      }
    }
    guys[a] = all;
    assert((int) all.size() <= BITS);
    for (int i = 0; i < (int) vrts.size(); i++) {
      color[vrts[i]] = i;
      who[vrts[i]] = a;
    }
    for (int i = 0; i < (int) vrts.size(); i++) {
      for (auto &v : g[vrts[i]]) {
        if (color[v] == -1) {

          draw(v);
        }
      }
    }
  };
  draw(root);
  ll solu = 0;
  int done = 0;

  set<pair<int, int>> s;

  while (sub[P] < BITS) {
    s.insert({P, parrent[P]});
    s.insert({parrent[P], P});
    V = Move(parrent[P]);
    P = parrent[P];
  }
  vector<pair<int, int>> all = guys[who[P]];

  function<bool(pair<int, int>, pair<int, int>)> cmp = [&] (pair<int, int> a, pair<int, int> b) {
    return s.count(a) < s.count(b);
  };

  sort(all.begin(), all.end(), cmp);

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

  for (auto &it : all) g[it.first].push_back(it.second), g[it.second].push_back(it.first);

  vector<int> dep(N);

  function<void(int, int)> cdep = [&] (int a, int p) {
    dep[a] = 0;
    for (auto &b : g[a]) {
      if (b != p) {
        cdep(b, a);
        dep[a] = max(dep[a], 1 + dep[b]);
      }
    }
  }

  function<void(int, int)> expl = [&] (int a, int p) {
    solu |= (1LL << color[a]) * V;
    done++;
    int v = -1;
    for (auto &b : g[a]) {
      if (b == p) continue;
      if (v == -1) v = b;
      else if (dep[b] > dep[v]) v = b;
    }
    for (auto &b : g[a]) {
      if (b == p || b == v) continue;
      if (done == BITS) break;
      V = Move(b);
      if (done == BITS) break;
      expl(b, a);
      if (done == BITS) break;
      V = Move(a);
      if (done == BITS) break;
    }
    for (auto &b : g[a]) {
      if (b == p || b != v) continue;
      if (done == BITS) break;
      V = Move(b);
      if (done == BITS) break;
      expl(b, a);
      if (done == BITS) break;
      V = Move(a);
      if (done == BITS) break;
    }
  };

  cdep(P, -1);
  expl(P, -1);

  assert(done == BITS);
  for (auto &x : color) assert(0 <= x && x < BITS);



  vector<int> numBits(BITS, -1);
  int needBits = BITS;


  return solu;
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:111:3: error: expected ',' or ';' before 'function'
  111 |   function<void(int, int)> expl = [&] (int a, int p) {
      |   ^~~~~~~~
Ioi.cpp:143:13: error: too many arguments to function 'long double expl(long double)'
  143 |   expl(P, -1);
      |             ^
In file included from /usr/include/c++/10/cmath:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Ioi.cpp:3:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:95:1: note: declared here
   95 | __MATHCALL_VEC (exp,, (_Mdouble_ __x));
      | ^~~~~~~~~~~~~~
Ioi.cpp:151:7: warning: unused variable 'needBits' [-Wunused-variable]
  151 |   int needBits = BITS;
      |       ^~~~~~~~