Submission #969149

# Submission time Handle Problem Language Result Execution time Memory
969149 2024-04-24T15:35:16 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);
    }
  }
}
 
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];
 
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);
  }
}
 
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]) {
      |             ^
/usr/bin/ld: /tmp/cciMFgfd.o: in function `main':
grader_anya.cpp:(.text.startup+0xde): undefined reference to `InitAnya(int, int*, int*)'
/usr/bin/ld: grader_anya.cpp:(.text.startup+0x1bf): undefined reference to `Anya(int*)'
collect2: error: ld returned 1 exit status

Boris.cpp: In function 'void dfs(long long int, 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 'bool query(long long int, long long int)':
Boris.cpp:24:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |   for (auto [v, x] : adj[u]) {
      |             ^
/usr/bin/ld: /tmp/ccwL3k1X.o: in function `main':
grader_boris.cpp:(.text.startup+0x17d): undefined reference to `InitBoris(int, int*, int*)'
collect2: error: ld returned 1 exit status