Submission #97063

# Submission time Handle Problem Language Result Execution time Memory
97063 2019-02-13T16:25:06 Z fefe Duathlon (APIO18_duathlon) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define MAX_N 100005
#define MAX_M 200005
#define pb push_back
#define mp make_pair
#define all(V) (V).begin(),(V).end()
#define reset(V) (V).clear();(V).resize(0);
#define sq(x) ((x)*(x))
#define abs(x) ((x)>0?(x):(-(x)))
#define fi first
#define se second
#define LL_inf (1LL<<60)
#define full_inf 0x7fffffff
#define half_inf 0x3fffffff
#define inf 0x3fffffff
#define MOD 1000000007LL
#define cpx_mod(x) (((LD)(((LL)x.real())%MOD)),((LD)(((LL)x.imag())%MOD)))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pil;
typedef pair<LL,string> pls;
typedef complex<LD> Complex;
typedef long double LD;
int n,m,ln,dep[MAX_N],loc[MAX_N],val[MAX_N];
LL ans;
bool vis[MAX_N];
vector<int> E[MAX_N],L,lst[MAX_N];
vector<pii> bcc[MAX_N];
void merge(int x,int y){
	int p,q;
	p=loc[x];
	q=loc[y];
	if(bcc[p].size()<bcc[q].size())	swap(p,q);
	loc[x]=p;
	while(bcc[q].size()){
		bcc[p].pb(bcc[q].back());		
		bcc[q].pop_back();
	}
}
int make_bcc(int x){
	int z=dep[x]-1,k;
	m++;
	loc[x]=ln++;
	bcc[loc[x]].pb({x,0});
	for(int y:E[x]){
		if(dep[y]){
			z=min(z,dep[y]);
			continue;
		}
		dep[y]=dep[x]+1;
		k=make_bcc(y);
		z=min(z,k);
		if(k==dep[x]){
			bcc[loc[y]].pb({x,0});
			L.pb(loc[y]);
			continue;
		}
		merge(x,y);
	}
	return z;
}
int dfs(int x,int y){
	int sum=0;
	vis[x]=true;
	for(pii &p:bcc[x]){
		p.se++;
		if(p.fi==y)	continue;
		for(int q:lst[p.fi]){
			if(vis[q])	continue;
			p.se+=dfs(q,p.fi)-1;
		}
	}
	for(pii p:bcc[x])	sum+=p.se;
	for(pii &p:bcc[x]){
		if(p.fi==y)	p.se=m-sum+1;
		ans+=((LL)(bcc[x].size()-2))*(LL)p.se*((LL)(m-p.se));
		ans+=2*((LL)val[p.fi])*((LL)(p.se-1));
		val[p.fi]+=(p.se-1);
	}
	return sum;
}
int main(){
	int i,x,y;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&x,&y);
		E[x].pb(y);
		E[y].pb(x);
	}
	for(i=1;i<=n;i++){
		if(dep[i])	continue;
		L.clear();
		L.resize(0);
		dep[i]=1;
		m=0;
		make_bcc(i);
		if(m<2)	continue;
		for(x:L){
			for(pii z:bcc[x]){
				lst[z.fi].pb(x);
			}
		}
		x=bcc[L[0]][0].fi;
		for(y:lst[x]){
			dfs(y,x);
		}
	}
	
	
	
	for(i=1;i<=n;i++)	dep[i]=0;	//dep --> count node under me
	
	printf("%lld\n",ans);
	return 0;
}

Compilation message

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:100:8: error: found ':' in nested-name-specifier, expected '::'
   for(x:L){
        ^
count_triplets.cpp:100:7: error: 'x' is not a class, namespace, or enumeration
   for(x:L){
       ^
count_triplets.cpp:105:4: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   x=bcc[L[0]][0].fi;
    ^
count_triplets.cpp:106:3: error: expected primary-expression before 'for'
   for(y:lst[x]){
   ^~~
count_triplets.cpp:106:3: error: expected ')' before 'for'
count_triplets.cpp:106:8: error: found ':' in nested-name-specifier, expected '::'
   for(y:lst[x]){
        ^
count_triplets.cpp:106:7: error: 'y' is not a class, namespace, or enumeration
   for(y:lst[x]){
       ^
count_triplets.cpp:109:2: error: expected primary-expression before '}' token
  }
  ^
count_triplets.cpp:109:2: error: expected ';' before '}' token
count_triplets.cpp:109:2: error: expected primary-expression before '}' token
count_triplets.cpp:109:2: error: expected ')' before '}' token
count_triplets.cpp:109:2: error: expected primary-expression before '}' token
count_triplets.cpp:86:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
count_triplets.cpp:88:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~