#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define nf endl
#define ll int
#define pb push_back
#define _ << ' ' <<
#define INF (ll)1e9
#define mod 998244353
#define maxn 1000010
ll i, i1, j, k, k1, t, n, m, res, flag[10], a, b;
ll ms[5], status;
vector<array<ll, 2>> el;
struct graph {
ll dg[maxn], cn3, cyc, pr[maxn], sz[maxn];
vector<ll> adj[maxn];
graph() {
ll i;
for (i = 1; i <= n; i++) {
dg[i] = 0; pr[i] = i; sz[i] = 1;
}
cn3 = 0; cyc = 0;
}
ll find(ll x) {
if (x == pr[x]) return x;
return pr[x] = find(pr[x]);
}
bool same(ll a, ll b) {
return (find(a) == find(b));
}
void onion(ll a, ll b) {
a = find(a); b = find(b);
if (a == b) {
cyc++; res = sz[a]; return;
}
if (sz[a] < sz[b]) swap(a, b);
pr[b] = a; sz[a] += sz[b];
}
void upd(ll p, ll x) {
cn3 -= (dg[p] >= 3);
dg[p] += x;
cn3 += (dg[p] >= 3);
}
};
graph gr[5];
void ins(ll p, ll a, ll b) {
if (ms[p] == a || ms[p] == b) return;
gr[p].upd(a, 1); gr[p].upd(b, 1);
gr[p].adj[a].pb(b); gr[p].adj[b].pb(a);
gr[p].onion(a, b);
}
void Init(int N_) {
n = N_;
gr[0] = graph(); gr[1] = graph(); gr[2] = graph(); gr[3] = graph(); gr[4] = graph();
}
void Link(int A, int B) {
a = A + 1; b = B + 1;
el.pb({a, b});
for (i = 0; i <= 4; i++) ins(i, a, b);
if (status == 0) {
if (gr[0].dg[b] >= 3) swap(a, b);
if (gr[0].dg[a] >= 3) {
status = 1;
ms[1] = a; ms[2] = gr[0].adj[a][0]; ms[3] = gr[0].adj[a][1]; ms[4] = gr[0].adj[a][2];
gr[1] = graph(); gr[2] = graph(); gr[3] = graph(); gr[4] = graph();
for (auto [x, y] : el) {
for (i = 1; i <= 4; i++) ins(i, x, y);
}
}
}
}
int CountCritical() {
// cout << "status =" _ status _ gr[0].cyc << nl;
if (status == 0) {
if (gr[0].cyc == 0) return n;
if (gr[0].cyc == 1) return res;
return 0;
}
res = 0;
for (i = 1; i <= 4; i++) {
if (gr[i].cyc + gr[i].cn3 == 0) res++;
}
return res;
}
Compilation message
rings.cpp:8:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas]
8 | #pragma GCC optimize("-funsafe-loop-optimizations")
| ^
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
10 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
| ^
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
rings.cpp:10:82: warning: bad option '-funsafe-loop-optimizations' to attribute 'op