CODE FESTIVAL 2016 Final

Submission #1102143

Source codeソースコード

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> lan[MAX_N];
int par[MAX_N];
int rank[MAX_N];

void initial(int n){		//初期化
	for(int i=0;i<n;i++){
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x){		//木の根を求める
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rank[x] < rank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}

int main()
{
	int n,m,k,L;
	bool flag = true;
	cin >> n >> m;
	rep(i,n){
		cin >> k;
		rep(j,k){
			scanf("%d",&L);
			lan[L-1].push_back(i);
		}
	}
	initial(n);
	rep(i,m){
		if(!lan[i].empty()){
			rep(j,lan[i].size()-1){
				if(lan[i].size()>=2){
					unite(lan[i][j],lan[i][j+1]);
				}
			}
		}
	}
	rep(i,n-1){
		if(!same(i,i+1)){
			flag = false;
			break;
		}
	}
	if(flag){
		cout << "YES" << "\n";
	}else{
		cout << "NO" << "\n";
	}
}

Submission

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

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

./Main.cpp: In function ‘void initial(int)’:
./Main.cpp:20:3: error: reference to ‘rank’ is ambiguous
rank[i] = 0;
^
./Main.cpp:15:5: note: candidates are: int rank [100005]
int rank[MAX_N];
^
In file included from /usr/include/c++/5/bits/move.h:57:0,
from /usr/include/c++/5/bits/stl_pair.h:59,
from /usr/include/c++/5/bits/stl_algobase.h:64,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/istream:38,
from /usr/include/c++/5/sstream:38,
from /usr/include/c++/5/complex:45,
from /usr/include/c++/5/ccomplex:38,
from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
from ./Main.cpp:1:
/usr/include/c++/5/type_traits:1415:12: note: template<class> struct std::rank
struct rank
^
./Main.cpp: In function ‘void unite(int, int)’:
./Main.cpp:36:5: err...

Test case