Submission #969148

# Submission time Handle Problem Language Result Execution time Memory
969148 2024-04-24T15:33:59 Z abczz None (JOI16_snowy) C++14
Compilation error
0 ms 0 KB
#include "Anyalib.h"
#include <iostream>
#include <array>
#include <vector>
#define ll long long
 
using namespace std;
 
vector <array<ll, 2> > adj[500];
vector <int> c;
ll n, sz, f, z, q, D[500], cnt[12];
 
void dfs(ll u, ll p, ll w) {
  D[u] = w;
  ++cnt[w];
  for (auto [v, x] : adj[u]) {
    if (v != p) dfs(v, u, (w+1)%12);
  }
}
 
void dfs2(ll u, ll p, ll w) {
  for (auto [v, x] : adj[u]) {
    if (v != p) {
      dfs2(v, u, w+c[x]);
      if (D[v] != z) Save(sz++, c[x]);
    }
  }
  if (u && D[u] == z) {
    for (int i=8; i>=0; --i) {
      if ((w & (1<<i))) Save(sz++, 1);
      else Save(sz++, 0);
    }
  }
}
 
bool query(ll u, ll p) {
  bool B = 0, res;
  if (u == q) B = 1;
  for (auto [v, x] : adj[u]) {
    if (v != p) {
      res = query(v, u);
      if (res) f += Ask(sz);
      if (D[v] != z) sz++;
      B |= res;
    }
  }
  if (u && D[u] == z) {
    for (int i=8; i>=0; --i) {
      if (B) f += Ask(sz)*(1<<i);
      sz++;
    }
    return 0;
  }
  return B;
}
 
void InitAnya(int N, std::vector<int> A, std::vector<int> B) {
  n = N;
  for (int i=0; i<N; ++i) {
    adj[i].clear();
  }
  for (int i=0; i<N-1; ++i) {
    adj[A[i]].push_back({B[i],i});
    adj[B[i]].push_back({A[i],i});
  }
  dfs(0, -1, 0);
  f = 1e18;
  for (int i=0; i<12; ++i) {
    if (f > cnt[i] && cnt[i]) {
      f = cnt[i];
      z = i;
    }
  }
}
 
void Anya(std::vector<int> C) {
  c = C;
  sz = 0;
  dfs2(0, -1, 0);
}
#include "Borislib.h"
#include <iostream>
#include <array>
#include <vector>
#define ll long long
 
using namespace std;
 
vector <array<ll, 2> > adj[500];
vector <int> c;
ll n, sz, f, z, q, D[500], cnt[12];

bool query(ll u, ll p) {
  bool B = 0, res;
  if (u == q) B = 1;
  for (auto [v, x] : adj[u]) {
    if (v != p) {
      res = query(v, u);
      if (res) f += Ask(sz);
      if (D[v] != z) sz++;
      B |= res;
    }
  }
  if (u && D[u] == z) {
    for (int i=8; i>=0; --i) {
      if (B) f += Ask(sz)*(1<<i);
      sz++;
    }
    return 0;
  }
  return B;
}
 
void InitBoris(int N, std::vector<int> A, std::vector<int> B) {
  n = N;
  for (int i=0; i<N; ++i) {
    adj[i].clear();
  }
  for (int i=0; i<N-1; ++i) {
    adj[A[i]].push_back({B[i],i});
    adj[B[i]].push_back({A[i],i});
  }
  dfs(0, -1, 0);
  f = 1e18;
  for (int i=0; i<12; ++i) {
    if (f > cnt[i] && cnt[i]) {
      f = cnt[i];
      z = i;
    }
  }
}
 
int Boris(int city) {
  q = city;
  f = sz = 0;
  query(0, -1);
  return f;
}

Compilation message

Anya.cpp: In function 'void dfs(long long int, long long int, long long int)':
Anya.cpp:16:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |   for (auto [v, x] : adj[u]) {
      |             ^
Anya.cpp: In function 'void dfs2(long long int, long long int, long long int)':
Anya.cpp:22:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |   for (auto [v, x] : adj[u]) {
      |             ^
Anya.cpp: In function 'bool query(long long int, long long int)':
Anya.cpp:39:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |   for (auto [v, x] : adj[u]) {
      |             ^
Anya.cpp:42:21: error: 'Ask' was not declared in this scope
   42 |       if (res) f += Ask(sz);
      |                     ^~~
Anya.cpp:49:19: error: 'Ask' was not declared in this scope
   49 |       if (B) f += Ask(sz)*(1<<i);
      |                   ^~~

Boris.cpp: In function 'bool query(long long int, long long int)':
Boris.cpp:16:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |   for (auto [v, x] : adj[u]) {
      |             ^
Boris.cpp: In function 'void InitBoris(int, std::vector<int>, std::vector<int>)':
Boris.cpp:43:3: error: 'dfs' was not declared in this scope
   43 |   dfs(0, -1, 0);
      |   ^~~