Submission #30450

# Submission time Handle Problem Language Result Execution time Memory
30450 2017-07-23T11:27:17 Z ozaslan Game (IOI14_game) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;

int p[1500], rank[1500], s[1500];
int dp[1500][1500], N;


void linkSet(int x, int y) {
	if (rank[x] > rank[y]) {
		p[y] = x;
		s[x] += s[y];

		for(int i = 0; i < N; i++)
			dp[x][i] += dp[y][i];
	}

	else {
		p[x] = y;
		rank[y]++;
		s[y] += s[x];

		for(int i = 0; i < N; i++)
			dp[y][i] += dp[x][i];
	}
}
int findSet(int x) {
	if(x != p[x])
		p[x] = findSet(p[x]);
	return p[x];
}
void makeSet(int x) {p[x] = x, rank[x] = 0, s[x] = 1; }
void unionSet(int x, int y) { linkSet(findSet(x), findSet(y)); }


void initialize(int n) {
	N = n;
	for(int i = 0; i < N; i++)
		makeSet(i);
}


int hasEdge(int u, int v) {
	int x = findSet(u);
	int y = findSet(v);
	if(x < y) swap(x, y);

	if(x == y) return 0;

	if(dp[x][y] == s[x]*s[y]-1) {
		unionSet(x, y);
		return 1;
	}

	dp[x][y]++;
	dp[y][x]++;
    return 0;
}

Compilation message

game.cpp: In function 'void linkSet(int, int)':
game.cpp:10:6: error: reference to 'rank' is ambiguous
  if (rank[x] > rank[y]) {
      ^
game.cpp:5:14: note: candidates are: int rank [1500]
 int p[1500], rank[1500], s[1500];
              ^
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 game.cpp:1:
/usr/include/c++/5/type_traits:1415:12: note:                 template<class> struct std::rank
     struct rank
            ^
game.cpp:10:16: error: reference to 'rank' is ambiguous
  if (rank[x] > rank[y]) {
                ^
game.cpp:5:14: note: candidates are: int rank [1500]
 int p[1500], rank[1500], s[1500];
              ^
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 game.cpp:1:
/usr/include/c++/5/type_traits:1415:12: note:                 template<class> struct std::rank
     struct rank
            ^
game.cpp:20:3: error: reference to 'rank' is ambiguous
   rank[y]++;
   ^
game.cpp:5:14: note: candidates are: int rank [1500]
 int p[1500], rank[1500], s[1500];
              ^
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 game.cpp:1:
/usr/include/c++/5/type_traits:1415:12: note:                 template<class> struct std::rank
     struct rank
            ^
game.cpp: In function 'void makeSet(int)':
game.cpp:32:32: error: reference to 'rank' is ambiguous
 void makeSet(int x) {p[x] = x, rank[x] = 0, s[x] = 1; }
                                ^
game.cpp:5:14: note: candidates are: int rank [1500]
 int p[1500], rank[1500], s[1500];
              ^
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 game.cpp:1:
/usr/include/c++/5/type_traits:1415:12: note:                 template<class> struct std::rank
     struct rank
            ^