QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#426795#3047. Wind of ChangeEw_CorsCompile Error//C++204.6kb2024-05-31 21:34:102024-05-31 21:34:10

Judging History

你现在查看的是最新测评结果

  • [2024-05-31 21:34:10]
  • 评测
  • [2024-05-31 21:34:10]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2.5e5 + 5;
using i64 = long long;
using E = vector<pair<int, int> >;
using V = vector<pair<int, i64> >;
int vis[N];
int siz[N];
void gsiz(int u, int fa, E *e) {
  siz[u] = 1;
  for (auto [v, w] : e[u]) {
    if (v == fa || vis[v]) {
      continue;
    }
    gsiz(v, u, e);
    siz[u] += siz[v];
  }
}
void frt(int u, int fa, int sm, int &rt, int &rsm, E *e) {
  int mxn = 0;
  for (auto [v, w] : e[u]) {
    if (v == fa || vis[v]) {
      continue;
    }
    frt(v, u, sm, rt, rsm, e);
    mxn = max(mxn, siz[v]);
  }
  if (u == fa) {
    if (mxn > rsm) {
      rsm = mxn;
      rt = u;
    }
  }
  if (min(mxn, sm - siz[u]) > rsm) {
    rsm = min(mxn, sm - siz[u]);
    rt = u;
  }
}
void fdp(int u, int fa, i64 dep, int rt, V *s, E *e) {
  s[u].push_back({rt, dep});
  for (auto [v, w] : e[u]) {
    if (v == fa || vis[v]) {
      continue;
    }
    fdp(v, u, dep + w, rt, s, e);
  }
}
void dfs(int u, V *s, E *e) {
  gsiz(u, u, e);
  int sm = siz[u], rt = 0, rsm = 0;
  frt(u, u, sm, rt, rsm, e);
  if (rt == 0) {
    s[u].push_back({u, 0});
    return;
  }
  fdp(rt, rt, 0, rt, s, e);
  vis[rt] = 1;
  for (auto [v, w] : e[rt]) {
    if (!vis[v]) {
      dfs(v, s, e);
    }
  }
}
int n;
E e[2][N];
V s[2][N];
V st[N];
void bld(int x) {
  for (int i = 1; i <= n; i++) {
    vis[i] = 0;
  }
  dfs(1, s[x], e[x]);
}
i64 dep[N];
i64 ans[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int o = 0; o < 2; o++) {
    for (int i = 1, u, v, w; i < n; i++) {
      cin >> u >> v >> w;
      e[o][u].push_back({v, w});
      e[o][v].push_back({u, w});
    }
  }
  bld(0);
  bld(1);
  for (int i = 1; i <= n; i++) {
    for (auto [f0, d0] : s[0][i]) {
      st[f0].push_back({i, d0});
    }
  }
  for (int i = 1; i <= n; i++) {
    dep[i] = 1e18;
    ans[i] = 1e18;
  }
  for (int c = 1; c <= n; c++) {
    for (auto [u, d] : st[c]) {
      for (auto [f1, d1] : s[1][u]) {
        ans[u] = min(ans[u], d + d1 + dep[f1]);
        dep[f1] = min(dep[f1], d + d1);
      }
    }
    for (auto [u, d] : st[c]) {
      for (auto [f1, d1] : s[1][u]) {
        dep[f1] = 1e18;
      }
    }
    for (auto it = st[c].rbegin(); it != st[c].rend(); it++) {
      auto [u, d] = *it;
      for (auto [f1, d1] : s[1][u]) {
        ans[u] = min(ans[u], d + d1 + dep[f1]);
        dep[f1] = min(dep[f1], d + d1);
      }
    }
    for (auto [u, d] : st[c]) {
      for (auto [f1, d1] : s[1][u]) {
        dep[f1] = 1e18;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Details

answer.code:23:39: warning: bad option ‘-fwhole-program’ to pragma ‘optimize’ [-Wpragmas]
   23 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
answer.code:30:41: warning: bad option ‘-fstrict-overflow’ to pragma ‘optimize’ [-Wpragmas]
   30 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
answer.code:32:41: warning: bad option ‘-fcse-skip-blocks’ to pragma ‘optimize’ [-Wpragmas]
   32 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
answer.code:46:51: warning: bad option ‘-funsafe-loop-optimizations’ to pragma ‘optimize’ [-Wpragmas]
   46 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
answer.code:57:30: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   57 | void gsiz(int u, int fa, E *e) {
      |                              ^
answer.code:57:30: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:57:30: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:57:30: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:67:56: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   67 | void frt(int u, int fa, int sm, int &rt, int &rsm, E *e) {
      |                                                        ^
answer.code:67:56: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:67:56: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:67:56: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:87:52: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   87 | void fdp(int u, int fa, i64 dep, int rt, V *s, E *e) {
      |                                                    ^
answer.code:87:52: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:87:52: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:87:52: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:96:27: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   96 | void dfs(int u, V *s, E *e) {
      |                           ^
answer.code:96:27: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:96:27: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:96:27: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:116:15: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  116 | void bld(int x) {
      |               ^
answer.code:116:15: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:116:15: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:116:15: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:124:10: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  124 | int main() {
      |          ^
answer.code:124:10: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:124:10: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:124:10: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
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 answer.code:49:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr 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’ ‘constexpr 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
      |              ^~~~~~~~~~~~