Submission #30449

#TimeUsernameProblemLanguageResultExecution timeMemory
30449ozaslanGame (IOI14_game)C++14
Compilation error
0 ms0 KiB
#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 (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:45:21: error: 'swap' was not declared in this scope
  if(x < y) swap(x, y);
                     ^