QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#131736 | #2760. Simurgh | pandapythoner# | Compile Error | / | / | C++20 | 4.1kb | 2023-07-27 22:38:21 | 2024-07-04 01:00:39 |
Judging History
你现在查看的是最新测评结果
- [2024-07-04 01:00:39]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-27 22:38:21]
- 提交
answer
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#else
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#endif
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;
#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
const ll inf = 1e18;
mt19937 rnd(234);
struct DSU {
int n;
vector<int> t;
void build(int _n) {
n = _n;
t.resize(n);
for (int i = 0; i < n; i += 1) {
t[i] = i;
}
}
};
struct edge {
int to, i;
};
bool operator==(const edge &a, const edge &b) {
return a.to == b.to && a.i == b.i;
}
int n, m;
vector<pair<int, int>> edgs;
vector<int> tp;
vector<vector<edge>> g;
vector<int> usd;
vector<int> h;
bool dfs0(int v, int mh, int pri, vector<int> &stck, vector<int> &cycle) {
h[v] = mh;
usd[v] = 1;
for (auto [to, i] : g[v]) {
if (pri == i) {
continue;
}
if (usd[to] == 1) {
int dst = mh - h[to];
cycle = vector<int>(stck.end() - dst, stck.end());
cycle.push_back(i);
return true;
}
if (usd[to] == 0) {
stck.push_back(i);
int x = dfs0(to, mh + 1, i, stck, cycle);
stck.pop_back();
if (x) {
return true;
}
}
}
usd[v] = 2;
return false;
}
void find_cycle(vector<int> &cycle) {
usd.assign(n, 0);
h.resize(n);
vector<int> stck;
stck.reserve(n);
dfs0(0, 0, -1, stck, cycle);
}
void dfs1(int v, vector<int> &rs) {
usd[v] = 1;
for (auto [to, i] : g[v]) {
if (!usd[to]) {
rs.push_back(i);
dfs1(to, rs);
}
}
}
vector<int> add_edgs(vector<int> &c) {
auto rs = c;
usd.assign(n, 0);
for (auto i : c) {
auto [u, v] = edgs[i];
usd[u] = 1;
usd[v] = 1;
}
for (auto i : c) {
auto [u, v] = edgs[i];
if (usd[u] == 1) {
dfs1(u, rs);
usd[u] = 2;
}
if (usd[v] == 1) {
dfs1(v, rs);
usd[v] = 2;
}
}
return rs;
}
void reveal_cycle(vector<int> &c) {
auto f = add_edgs(c);
int sz = (int)c.size();
vector<int> p(sz, -1);
int mx = 0;
for (int i = 0; i < sz; i += 1) {
int j = c[i];
if (tp[j] == -1) {
auto nf = f;
nf.erase(nf.begin() + i);
p[i] = count_common_roads(nf);
mx = max(mx, p[i]);
}
}
for (int i = 0; i < sz; i += 1) {
int j = c[i];
if (tp[j] == -1) {
if (p[i] == mx) {
tp[j] = 0;
} else {
tp[j] = 1;
}
}
}
}
void erase(vector<edge> &t, const edge &x) {
for (int i = 0; i < (int)t.size(); i += 1) {
if (t[i] == x) {
t.erase(t.begin() + i);
break;
}
}
}
void delete_edge_from_g(int i) {
auto [u, v] = edgs[i];
erase(g[u], edge{v, i});
erase(g[v], edge{u, i});
}
vector<int> solve_slow() {
tp.assign(m, -1);
g.assign(n, vector<edge>());
for (int i = 0; i < m; i += 1) {
auto [u, v] = edgs[i];
g[u].push_back(edge{v, i});
g[v].push_back(edge{u, i});
}
int cnt = m;
while (cnt > n - 1) {
vector<int> c;
find_cycle(c);
reveal_cycle(c);
for (auto j : c) {
if (tp[j] == 0) {
delete_edge_from_g(j);
cnt -= 1;
}
}
}
vector<int> rs;
for (int v = 0; v < n; v += 1) {
for (auto [to, i] : g[v]) {
if (to < v) {
rs.push_back(i);
}
}
}
return rs;
}
vector<int> find_roads(int _n, vector<int> _u, vector<int> _v) {
n = _n;
m = _u.size();
edgs.resize(m);
for (int i = 0; i < m; i += 1) {
edgs[i] = make_pair(_u[i], _v[i]);
}
auto rs = solve_slow();
return rs;
}
Details
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:8: /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 | ^~~~~~~~~~~~