Submission #511064

# Submission time Handle Problem Language Result Execution time Memory
511064 2022-01-15T05:12:17 Z tabr Tropical Garden (IOI11_garden) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

#include "garden.h"
#include "gardenlib.h"

void count_routes(int n, int m, int p, int r[][2], int q, int k[]) {
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        g[r[i][0]].emplace_back(g[r[i][1]]);
        g[r[i][1]].emplace_back(g[r[i][0]]);
    }
    vector<vector<int>> nxt(30, vector<int>(2 * n));
    for (int i = 0; i < n; i++) {
        nxt[0][i] = g[i][0] + n;
        nxt[0][i + n] = g[i][min((int) g[i].size(), 1)];
    }
    for (int i = 1; i < 30; i++) {
        for (int j = 0; j < 2 * n; j++) {
            nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
        }
    }
    for (int i = 0; i < q; i++) {
        int ans = 0;
        for (int j = 0; j < n; j++) {
            int v = j;
            for (int l = 29; l >= 0; l--) {
                if (k[i] & (1 << l)) {
                    v = nxt[l][v];
                }
            }
            if (v == p % n) {
                ans++;
            }
        }
        answer(ans);
    }
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    return 0;
}
#endif

Compilation message

In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/string:41,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from garden.cpp:1:
/usr/include/c++/10/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int; _Args = {std::vector<int, std::allocator<int> >&}; _Tp = int]':
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {std::vector<int, std::allocator<int> >&}; _Tp = int; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<int>]'
/usr/include/c++/10/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::vector<int, std::allocator<int> >&}; _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&]'
garden.cpp:15:43:   required from here
/usr/include/c++/10/ext/new_allocator.h:150:4: error: cannot convert 'std::vector<int>' to 'int' in initialization
  150 |  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~