/ SeriousOJ /

Record Detail

Compile Error

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 foo.cc:1:
/usr/include/c++/13/bits/allocator.h: In function 'void solve(int)':
/usr/include/c++/13/bits/allocator.h:163:7: error: inlining failed in call to 'always_inline' 'constexpr std::allocator< <template-parameter-1-1> >::allocator() noexcept [with _Tp = std::vector<int>]': target specific option mismatch
  163 |       allocator() _GLIBCXX_NOTHROW { }
      |       ^~~~~~~~~
foo.cc:22:26: note: called from here
   22 |   vector<vector<int>> g(n);
      |                          ^
/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::vector<int>]': target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
foo.cc:22:26: note: called from here
   22 |   vector<vector<int>> g(n);
      |                          ^
/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::vector<int>]': target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
foo.cc:22:26: note: called from here
   22 |   vector<vector<int>> g(n);
      |                          ^

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("sse,sse2,mmx")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimize("inline")
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("fast-math")
#pragma GCC target("arch=core-avx2")

using namespace std;

void solve(int cs) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v, --u, --v;
    g[u].push_back(v);
    g[v].push_back(u); 
  }
  auto ispal = [&](string t) -> bool {
    for (int i = 0, j = t.size() - 1; j > i; i++, j--) if (t[i] != t[j]) return false;return true;
  };
  int q;
  cin >> q;
  while (q--) {
    int i;char c;
    cin >> i >> c;
    s[i - 1] = c;
    int res = 1;
    string t; t += s[0];
    auto dfs = [&](auto &&self, int node, int par) -> void {
      if (ispal(t)) {
        res = max(res, (int)t.size());
      }
      for (auto &nodes : g[node]) {
        if (nodes != par) {
          t += s[nodes];
          self(self, nodes, node);
          t.pop_back();
        }
      }
    };
    dfs(dfs, 0, -1);
    cout << res << "\n";
  }
  
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  // cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1045 Largest palindrome in tree
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-11 13:30:07
Judged At
2024-11-11 03:27:24
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes