제출 #1118729

#제출 시각아이디문제언어결과실행 시간메모리
1118729Ntd123철인 이종 경기 (APIO18_duathlon)C++14
49 / 100
1161 ms1048576 KiB
#include <bits/stdc++.h> #define PB push_back #define F first #define S second #define all(x) x.begin(), x.end() #define bit(x, i) ((x >> i) & 1) #define il (node * 2) #define ir (il + 1) #define mid (l + r)/2 #define maxn #define ll long long #define pii pair <int, int> #define MOD 1000000007 #define Task "b2" #define int long long using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 100005; int n, m, d, cnt = 0, com = 0, ans = 0; int luu[N], low[N], s[N]; stack <int> st; vector <int> a[N], tree[N]; void DFS(int x, int y){ st.push(x); d++; luu[x] = low[x] = ++ cnt; for (int i: a[x]){ if (i == y) continue; if (luu[i]) low[x] = min(low[x], luu[i]); else { DFS(i, x); low[x] = min(low[x], low[i]); if (luu[x] <= low[i]){ com++; tree[x].PB(com); while (!tree[com].size() || tree[com].back() != i) tree[com].PB(st.top()), st.pop(); } } } } void DFS1(int x){ s[x] = (x <= n); for (int i: tree[x]){ DFS1(i); s[x] += s[i]; if (i <= n) ans -= tree[x].size()*s[i]*(s[i]-1); } if (x > n) ans -= tree[x].size()*(d-s[x])*(d-s[x]-1); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n >> m; com = n; for (int i = 1; i <= m; i ++){ int u, v; cin >> u >> v; a[u].PB(v); a[v].PB(u); } for (int i = 1; i <= n; i ++) if (!luu[i]){ d=0; DFS(i, 0); ans += d*(d-1)*(d-2); DFS1(i); } cout << ans; cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(Task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
count_triplets.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen(Task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...