Submission #1833879


Source Code Expand

#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
 
typedef vector<int> vertex;
typedef vector<vertex> graph;
 
ll n, m;
graph g;
 
void add_edge(int a, int b){
	g[a].push_back(b);
	g[b].push_back(a);
}
 
int used[100000];
 
ll cnt(ll u, ll d, bool &tr){
	if(used[u]){
		if(used[u]!=2-d) tr = true;
		return 0;
	}
	used[u] = 2-d;
	ll res = 0;
	if(d==0) res++;
	for(int v: g[u]){
		res += cnt(v, !d, tr);
	}
	return res;
}
 
int main(){
	cin>>n>>m;
	g = graph(n);
	rep(i, m){
		int a, b;
		cin>>a>>b;
		a--; b--;
		add_edge(a, b);
	}
	bool tr = false;
	ll t = cnt(0, 0, tr);
	if(tr) cout<<n*(n-1)/2-m<<endl;
	else cout<<t*(n-t)-m<<endl;
	return 0;
}

Submission Info

Submission Time
Task C - 3 Steps
User Lepton
Language C++14 (GCC 5.4.1)
Score 0
Code Size 812 Byte
Status CE

Compile Error

./Main.cpp:9:9: error: ‘vector’ does not name a type
 typedef vector<int> vertex;
         ^
./Main.cpp:10:9: error: ‘vector’ does not name a type
 typedef vector<vertex> graph;
         ^
./Main.cpp:12:1: error: ‘ll’ does not name a type
 ll n, m;
 ^
./Main.cpp:13:1: error: ‘graph’ does not name a type
 graph g;
 ^
./Main.cpp: In function ‘void add_edge(int, int)’:
./Main.cpp:16:2: error: ‘g’ was not declared in this scope
  g[a].push_back(b);
  ^
./Main.cpp: At global scope:
./Main.cpp:22:1: error: ‘ll’ does not name a type
 ll cnt(ll u, ll d, bool &tr){
 ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:37:2: error: ‘cin’ was not declared in this scope
  cin>>n>>m;
  ^
./Main.cpp:37:2: note: suggested alternative:
In file included from ./Main.cpp:5:0:
/usr/include/c++/5/iostream:60:18: note:   ‘std::cin’
   extern istream cin;  /// Linked to standard input
                  ^
./Main.cpp:37:7: error: ‘n’ was not declared in this scope
  cin>>n>>m;
       ^
./Main.cpp:37:10: error: ‘m’ was not decla...