Submission #1276727

#TimeUsernameProblemLanguageResultExecution timeMemory
1276727TINMuseum (CEOI17_museum)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 1;

int n, k, s;
vector<pair<int,int>> adj[N];
int sz[N];
int dp[N][N][2];

void Task() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void Input() {
    memset(dp, 0x3f, sizeof(dp));
    cin >> n >> k >> s;
    for (int i = 1; i < n; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
}

int limu, limv;

void DFS(int u, int par) {
    dp[u][0][0] = 0;
    dp[u][1][0] = dp[u][1][1] = 0;
    sz[u] = 1;
    for (auto e : adj[u]) {
        int v, w;
        tie(v, w) = e;
        if (v ^ par) {
            DFS(v, u);
            sz[u] += sz[v];
            limu = min(sz[u], k);
            for (int x = limu; x >= 2; x--) {
                limv = min(sz[v], x);
                for (int y = 1; y <= limv; y++) {
                    dp[u][x][0] = min(dp[u][x][0], dp[u][x - y][0] + dp[v][y][0] + w * 2);
                    dp[u][x][1] = min(dp[u][x][1], dp[u][x - y][0] + w + dp[v][y][1]);
                    dp[u][x][1] = min(dp[u][x][1], dp[u][x - y][1] + dp[v][y][0] + w * 2);
                }
            }
        }
    }
}

void solve() {
    DFS(s, s);
    cout << min(dp[s][k][0], dp[s][k][1]) << '\n';
}

void Solve() {
    Input();
    solve();
}

int main() {
    Task();
    Solve();
    return 2231^2231;
}

Compilation message (stderr)

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from museum.cpp:3:
/usr/include/c++/13/bits/allocator.h: In destructor 'std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int> > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<int, int>]': target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~