Submission #414525

#TimeUsernameProblemLanguageResultExecution timeMemory
414525hhhhauraDuathlon (APIO18_duathlon)C++14
23 / 100
1091 ms30164 KiB
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define ceil(a, b) ((a + b - 1) / (b)) #define all(x) x.begin(), x.end() #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define int long long int #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} #else #define print(...) 0 #define vprint(...) 0 #endif namespace solver { int n, timestamp, ii, bccid, ans, cnt; vector<int> L, D, pre, es, sz; vector<vector<int>> mp1, mp2; void init_(int _n) { n = _n, timestamp = 0; ii = 0, bccid = 0, ans = 0; L.assign(n + 1, 0); D.assign(n + 1, 0); pre.assign(n + 1, 0); mp1.assign(n + 1, vector<int>()); mp2.assign(2 * n + 1, vector<int>()); sz.assign(2 * n + 1, 0); } void add_edge(int a, int b) { mp1[a].push_back(es.size()); mp1[b].push_back(es.size()); es.push_back(a ^ b); } void dfs1(int x, int par) { cnt ++, pre[ii++] = x; L[x] = D[x] = ++timestamp; for(auto i : mp1[x]) if(i != par) { int to = es[i] ^ x; if(D[to]) L[x] = min(D[to], L[x]); else { dfs1(to, i); L[x] = min(L[x], L[to]); if(L[to] >= D[x]) { bccid ++; mp2[n + bccid].push_back(x); mp2[x].push_back(n + bccid); while(pre[ii] != to) { ii --; mp2[n + bccid].push_back(to); mp2[to].push_back(n + bccid); } } } } return; } void dfs2(int x, int par) { if(x <= n) sz[x] = 1; for(auto i : mp2[x]) if(i != par) { dfs2(i, x), sz[x] += sz[i]; if(x > n) ans -= (mp2[x].size() - 1) * sz[i] * (sz[i] - 1); } if(x > n) ans -= (mp2[x].size() - 1) * (cnt - sz[x]) * (cnt - sz[x] - 1); } int solve() { rep(i, 1, n) if(!D[i]) { cnt = 0, dfs1(i, -1); ans += cnt * (cnt - 1) * (cnt - 2); dfs2(i, i); } return ans; } }; using namespace solver; signed main() { ios::sync_with_stdio(false), cin.tie(0); int n, m; cin >> n >> m; init_(n); rep(i, 1, m) { int a, b; cin >> a >> b; add_edge(a, b); } cout << solve() << "\n"; return 0; }

Compilation message (stderr)

count_triplets.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
count_triplets.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
count_triplets.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...