QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#316663 | #7177. Many Many Cycles | Minhho | Compile Error | / | / | C++17 | 2.3kb | 2024-01-28 01:24:00 | 2024-01-28 01:24:00 |
Judging History
answer
#define taskname "C"
#include <bits/stdc++.h>
#define int long long
#define ii pair<int,int>
#define ff first
#define ss second
using namespace std;
const int maxn = 1e4 + 10;
vector<ii> adj[maxn];
int pa[maxn][20], dep[maxn], dis[maxn], p[maxn], n, m;
array<int, 4> e[maxn];
inline int fp(int u) {return !p[u] ? u : p[u] = fp(p[u]);}
inline bool uni(int u, int v)
{
if ((u = fp(u)) == (v = fp(v))) return 0;
return p[v] = u;
}
void DFS(int u = 1, int par = 0)
{
for (auto [v, c]: adj[u]) if (v != par)
{
dep[v] = dep[u] + 1;
dis[v] = dis[u] + c;
pa[v][0] = u;
DFS(v, u);
}
}
inline int lca(int u, int v)
{
if (dep[u] > dep[v]) swap(u, v);
int dif = dep[v] - dep[u];
for (int i=19; i>=0; i--) if (dif >> i & 1) v = pa[v][i];
if (v == u) return u;
for (int i=19; i>=0; i--) if (pa[v][i] != pa[u][i]) v = pa[v][i], u = pa[u][i];
return pa[u][0];
}
inline int cal(int u, int v) {return dis[u] + dis[v] - 2 * dis[lca(u, v)];}
inline int sol(int m, int u, int v, int add)
{
if (dep[u] > dep[v]) swap(u, v);
if (cal(m, u) + cal(m, v) == cal(u, v)) return 0;
return add + cal(u, v);
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin>>n>>m;
for (int i=1; i<=m; i++) cin>>e[i][1]>>e[i][2]>>e[i][0], e[i][3] = i;
vector<int> ve;
for (int i=1; i<=m; i++) if (uni(e[i][1], e[i][2]))
{
adj[e[i][1]].emplace_back(e[i][2], e[i][0]);
adj[e[i][2]].emplace_back(e[i][1], e[i][0]);
} else ve.emplace_back(i);
DFS();
for (int i=1; i<20; i++)
for (int j=1; j<=n; j++)
pa[j][i] = pa[pa[j][i-1]][i-1];
int ans = 0;
for (int i=0; i<ve.size()-1; i++)
for (int j=i+1; j<ve.size(); j++)
{
auto [c1, u1, v1, id1] = e[ve[i]];
auto [c2, u2, v2, id2] = e[ve[j]];
if (u1 == u2) ans = __gcd(ans, sol(u1, v1, v2, add));
else if (u1 == v2) ans = __gcd(ans, sol(u1, u2, v1, add));
else if (v1 == u2) ans = __gcd(ans, sol(v1, u1, v2, add));
else if (v1 == v2) ans = __gcd(ans, sol(v1, u1, u2, add));
}
for (int i: ve)
{
auto [c, u, v, id] = e[i];
ans = __gcd(ans, c + cal(u, v));
}
cout<<ans;
}
Details
answer.code: In function ‘int main()’: answer.code:76:60: error: ‘add’ was not declared in this scope; did you mean ‘std::filesystem::perm_options::add’? 76 | if (u1 == u2) ans = __gcd(ans, sol(u1, v1, v2, add)); | ^~~ | std::filesystem::perm_options::add In file included from /usr/include/c++/13/filesystem:48, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200, from answer.code:2: /usr/include/c++/13/bits/fs_fwd.h:211:7: note: ‘std::filesystem::perm_options::add’ declared here 211 | add = 0x2, | ^~~ answer.code:77:65: error: ‘add’ was not declared in this scope; did you mean ‘std::filesystem::perm_options::add’? 77 | else if (u1 == v2) ans = __gcd(ans, sol(u1, u2, v1, add)); | ^~~ | std::filesystem::perm_options::add /usr/include/c++/13/bits/fs_fwd.h:211:7: note: ‘std::filesystem::perm_options::add’ declared here 211 | add = 0x2, | ^~~ answer.code:78:65: error: ‘add’ was not declared in this scope; did you mean ‘std::filesystem::perm_options::add’? 78 | else if (v1 == u2) ans = __gcd(ans, sol(v1, u1, v2, add)); | ^~~ | std::filesystem::perm_options::add /usr/include/c++/13/bits/fs_fwd.h:211:7: note: ‘std::filesystem::perm_options::add’ declared here 211 | add = 0x2, | ^~~ answer.code:79:65: error: ‘add’ was not declared in this scope; did you mean ‘std::filesystem::perm_options::add’? 79 | else if (v1 == v2) ans = __gcd(ans, sol(v1, u1, u2, add)); | ^~~ | std::filesystem::perm_options::add /usr/include/c++/13/bits/fs_fwd.h:211:7: note: ‘std::filesystem::perm_options::add’ declared here 211 | add = 0x2, | ^~~