답안 #759333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759333 2023-06-16T07:42:54 Z Trisanu_Das 철인 이종 경기 (APIO18_duathlon) C++17
컴파일 오류
0 ms 0 KB
#incude <bits/stdc++.h>
using namespace std;
#define int long long

int n, m, c, low[100005], dfn[100005], avsub[100005], sub[100005], st[100005], top=-1, dft, ans, c;
vector<int> adj[100005];
bool vis[100005];

void cc_cnt(int u){
  vis[u] = true; c++;
  for(int v : adj[u]) if(!vis[v]) cc_cnt(v);
}

void dfs(int u,int f) {
	low[u]=dfn[u]=++dft,sub[u]=1,ans+=(c-1)*(c-1),avsub[u]=1,st[++top]=u;
	for(int i:adj[u])
		if(i!=f)
			if(!dfn[i]) {
				dfs(i,u),sub[u]+=sub[i];
				if(low[i]>=dfn[u]) {
					ll sq=0,sz=0;
					avsub[u]+=sub[i];
					for(int x=-1;x!=i;) x=st[top--],sq+=(ll)avsub[x]*avsub[x],++sz;
					ans-=sz*((c-sub[i])*(c-sub[i])+sq);
				}
				else low[u]=min(low[u],low[i]);
			}
			else if(dfn[u]>dfn[i]) low[u]=min(low[u],dfn[i]);
}

signed main(){
  cin >> n >> m;
  while(m--){
    int u, v; cin >> u >> v;
    adj[u].push_back(v); adj[v].push_back(u);
  }
  for(int i=1;i<=n;++i) if(!vis[i]) c=0, cc_cnt(i), dfs(i,i);
	cout << ans << "\n";
}

Compilation message

count_triplets.cpp:1:2: error: invalid preprocessing directive #incude; did you mean #include?
    1 | #incude <bits/stdc++.h>
      |  ^~~~~~
      |  include
count_triplets.cpp:5:98: error: redefinition of 'long long int c'
    5 | int n, m, c, low[100005], dfn[100005], avsub[100005], sub[100005], st[100005], top=-1, dft, ans, c;
      |                                                                                                  ^
count_triplets.cpp:5:11: note: 'long long int c' previously declared here
    5 | int n, m, c, low[100005], dfn[100005], avsub[100005], sub[100005], st[100005], top=-1, dft, ans, c;
      |           ^
count_triplets.cpp:6:1: error: 'vector' does not name a type
    6 | vector<int> adj[100005];
      | ^~~~~~
count_triplets.cpp: In function 'void cc_cnt(long long int)':
count_triplets.cpp:11:15: error: 'adj' was not declared in this scope
   11 |   for(int v : adj[u]) if(!vis[v]) cc_cnt(v);
      |               ^~~
count_triplets.cpp: In function 'void dfs(long long int, long long int)':
count_triplets.cpp:16:12: error: 'adj' was not declared in this scope
   16 |  for(int i:adj[u])
      |            ^~~
count_triplets.cpp:21:6: error: 'll' was not declared in this scope
   21 |      ll sq=0,sz=0;
      |      ^~
count_triplets.cpp:23:38: error: 'sq' was not declared in this scope; did you mean 'st'?
   23 |      for(int x=-1;x!=i;) x=st[top--],sq+=(ll)avsub[x]*avsub[x],++sz;
      |                                      ^~
      |                                      st
count_triplets.cpp:24:11: error: 'sz' was not declared in this scope; did you mean 'st'?
   24 |      ans-=sz*((c-sub[i])*(c-sub[i])+sq);
      |           ^~
      |           st
count_triplets.cpp:24:37: error: 'sq' was not declared in this scope; did you mean 'st'?
   24 |      ans-=sz*((c-sub[i])*(c-sub[i])+sq);
      |                                     ^~
      |                                     st
count_triplets.cpp:26:17: error: 'min' was not declared in this scope
   26 |     else low[u]=min(low[u],low[i]);
      |                 ^~~
count_triplets.cpp:28:34: error: 'min' was not declared in this scope
   28 |    else if(dfn[u]>dfn[i]) low[u]=min(low[u],dfn[i]);
      |                                  ^~~
count_triplets.cpp:17:5: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   17 |   if(i!=f)
      |     ^
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:32:3: error: 'cin' was not declared in this scope
   32 |   cin >> n >> m;
      |   ^~~
count_triplets.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | #incude <bits/stdc++.h>
count_triplets.cpp:35:5: error: 'adj' was not declared in this scope
   35 |     adj[u].push_back(v); adj[v].push_back(u);
      |     ^~~
count_triplets.cpp:38:2: error: 'cout' was not declared in this scope
   38 |  cout << ans << "\n";
      |  ^~~~
count_triplets.cpp:38:2: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?