AtCoder Grand Contest 010

Submission #1357967

Source codeソースコード

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int N=3010;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int s[N],deg[N],q[N];
bool win[N];
int head[N],next[N],to[N];
int main()
{
	int n=gi(),i,a,b,tot=0,l=0,r=0,k;
	for (i=1;i<=n;i++) s[i]=gi();
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		if (s[a]>s[b]) swap(a,b);
		if (s[a]<s[b])
			deg[to[++tot]=b]++,next[tot]=head[a],head[a]=tot;
	}
	for (i=1;i<=n;i++) if (!deg[i]) q[++r]=i;
	while (l!=r)
		if (!win[k=q[++l]])
			for (i=head[k];i;i=next[i]) {
				win[to[i]]=true;
				if (!--deg[to[i]]) q[++r]=to[i];
			}
	for (i=1;i<=n;i++) if (win[i]) printf("%d ",i);
	return 0;
}

Submission

Task問題 F - Tree Game
User nameユーザ名 laofu
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 CE
Score得点 -
Source lengthソースコード長 987 Byte
File nameファイル名
Exec time実行時間 -
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:23: error: reference to ‘next’ is ambiguous
deg[to[++tot]=b]++,next[tot]=head[a],head[a]=tot;
^
./Main.cpp:23:13: note: candidates are: int next [3010]
int head[N],next[N],to[N];
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:66:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from ./Main.cpp:1:
/usr/include/c++/5/bits/stl_iterator_base_funcs.h:184:5: note: template<class _ForwardIterator> _ForwardIterator std::next(_ForwardIterator, typename std::iterator_traits<_Iter>::difference_type)
next(_ForwardIterator __x, typename
^
./Main.cpp:37:23: error: reference to ‘next’ is ambiguous
for (i=head[k];i;i=next[i]) {
^
./Main.cpp:23:13: note: candidates are: int nex...

Test case