Submission #1833881


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))
using namespace std;
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 831 Byte
Status CE

Compile Error

./Main.cpp:12:1: error: ‘ll’ does not name a type
 ll n, m;
 ^
./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:7: error: ‘n’ was not declared in this scope
  cin>>n>>m;
       ^
./Main.cpp:37:10: error: ‘m’ was not declared in this scope
  cin>>n>>m;
          ^
./Main.cpp:7:37: error: ‘ll’ was not declared in this scope
 #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
                                     ^
./Main.cpp:39:2: note: in expansion of macro ‘rep’
  rep(i, m){
  ^
./Main.cpp:46:2: error: ‘ll’ was not declared in this scope
  ll t = cnt(0, 0, tr);
  ^
./Main.cpp:48:13: error: ‘t’ was not declared in this scope
  else cout<<t*(n-t)-m<<endl;
             ^