Submission #516902

#TimeUsernameProblemLanguageResultExecution timeMemory
516902mansurDuathlon (APIO18_duathlon)C++17
5 / 100
79 ms28996 KiB
#include<bits/stdc++.h> #pragma optimize ("g",on) #pragma GCC optimize ("inline") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") #pragma comment(linker, "/stack:200000000") //01001101 01100001 01101011 01101000 01100001 01100111 01100001 01111001 using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ll long long #define pb push_back #define sz(a) a.size() #define nl '\n' #define popb pop_back() #define ld double #define ull unsigned long long #define ff first #define ss second #define fix fixed << setprecision #define pii pair<int, int> #define E exit (0) #define int long long const int inf = 1e15, N = 1e6, mod = 998244353; double eps = 1e-6; vector<pii> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; bool can[(1 << 10)][10][10], was[N]; vector<int> h[10][10], adj[N]; int d, v; void dfs(int u) { was[u] = 1; v++; for (auto e: adj[u]) { d++; if (!was[e]) { dfs(e); } } } main() { //freopen("F.in", "r", stdin); //freopen("F.out", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(NULL); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v; cin >> u >> v; u--, v--; adj[u].pb(v); adj[v].pb(u); } if (n <= 10) { for (int i = 0; i < n; i++) { can[(1 << i)][i][i] = 1; } for (int mask = 1; mask < (1 << n); mask++) { for (int s = 0; s < n; s++) { if (!(mask >> s & 1)) continue; for (int f = 0; f < n; f++) { if (!(mask >> f & 1) || f == s) continue; for (auto e: adj[f]) { if (!(mask >> e & 1)) continue; can[mask][s][f] |= can[mask ^ (1 << f)][s][e]; } if (can[mask][s][f]) { h[s][f].pb(mask); } } } } int ans = 0; for (int s = 0; s < n; s++) { for (int c = 0; c < n; c++) { for (int f = 0; f < n; f++) { if (f == c || f == s || s == c) continue; bool ok = 0; for (auto a: h[s][c]) { for (auto b: h[c][f]) { if ((a & b) == (1 << c)) ok = 1; if (ok) break; } if (ok) break; } ans += ok; } } } cout << ans; }else { int ans = 0; for (int i = 0; i < n; i++) { if (!was[i]) { v = 0, d = 0; dfs(i); d /= 2; if (v < 3) continue; if (d == v * 2) ans += v * (v - 1) * (v - 2); else { for (int j = 1; j <= v - 2; j++) { ans += (v - j) * (v - j - 1); } } } } cout << ans; } }

Compilation message (stderr)

count_triplets.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      | 
count_triplets.cpp:9: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    9 | #pragma comment(linker, "/stack:200000000")
      | 
count_triplets.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main() {
      | ^~~~
#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...