Submission #1586030


Source Code Expand

#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,m,I,P,Q;
int cnt,head[100010],to[400010],next[400010],linker[100010];
bool f,vis[100010];
void add(int x,int y)
{
	cnt++;
	to[cnt]=y;
	next[cnt]=head[x];
	head[x]=cnt;
}
void dfs(int x,int fa)
{
	vis[x]=true;
	linker[x]=linker[fa]^1;
	for (int i=head[x];i;i=next[i])
	{
		int y=to[i];
		if (y!=fa)
		{
			if (vis[y])
			{
				if (linker[x]==linker[y])
				{
					f=true;
				}
				continue;
			}
			else
			{
				dfs(y,x);
			}
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	int x,y;
	for (int i=0;i<m;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	for (int i=1;i<=n;i++)
	{
		if (!vis[i])
		{
			if (head[i])
			{
				I++;
				vis[i]=true;
				continue;
			}
			f=false;
			dfs(i,0);
			if (f)
			{
				P++;
			}
			else
			{
				Q++;
			}
		}
	}
	long long ans=2LL*I*n-1LL*I*I+1LL*P*P+2LL*P*Q+2LL*Q*Q;
	printf("%lld\n",ans);
    return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User Emma194
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1969 Byte
Status CE

Compile Error

./Main.cpp:64:2: error: reference to 'next' is ambiguous
        next[cnt]=head[x];
        ^
./Main.cpp:58:33: note: candidate found by name lookup is 'next'
int cnt,head[100010],to[400010],next[400010],linker[100010];
                                ^
/usr/local/include/c++/v1/iterator:525:1: note: candidate found by name lookup is 'std::__1::next'
next(_InputIter __x,
^
./Main.cpp:71:25: error: reference to 'next' is ambiguous
        for (int i=head[x];i;i=next[i])
                               ^
./Main.cpp:58:33: note: candidate found by name lookup is 'next'
int cnt,head[100010],to[400010],next[400010],linker[100010];
                                ^
/usr/local/include/c++/v1/iterator:525:1: note: candidate found by name lookup is 'std::__1::next'
next(_InputIter __x,
^
2 errors generated.