Submission #595409

#TimeUsernameProblemLanguageResultExecution timeMemory
595409birthdaycakeGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include "game.h" #include<bits/stdc++.h> #define endl '\n' #define mod 1000000007 using namespace std; int arr[1501][1501]; set<int>cnt[2000001]; int adj[1501][1501]; int dsu[2000001],rnk[2000001]; int N; int Find(int x){ if(dsu[x] == x) return x; return dsu[x] = Find(dsu[x]); } void Unite(int a, int b){ a = Find(a); b = Find(b); if(rnk[a] < rnk[b]) swap(a,b); rnk[a] += rnk[b]; dsu[b] = a; set<int>d; for(int s = 1; s <= n; s++){ int x = Find(s); if(!arr[b][x]) continue; if(d.count(x)) continue; if(x == a) continue; arr[a][x] = 1; arr[x][a] = 1; d.insert(x); adj[a][x] += adj[x][b]; adj[x][a] += adj[b][x]; } } void initialize(int n) { N = n; for(int i = 1; i <= n; i++) { dsu[i] = i; rnk[i] = 1; } } int hasEdge(int u, int v) { u++; v++; int set_a = Find(u), set_b = Find(v); if(set_a == set_b) return 0; arr[set_a][set_b] = 1; arr[set_b][set_a] = 1; adj[set_a][set_b]++; adj[set_b][set_a]++; if(adj[set_a][set_b] != rnk[set_b] * rnk[set_a]) return 0; if(adj[set_b][set_a] != rnk[set_a] * rnk[set_b]) return 0; Unite(u,v); return 1; }

Compilation message (stderr)

game.cpp: In function 'void Unite(int, int)':
game.cpp:25:25: error: 'n' was not declared in this scope
   25 |     for(int s = 1; s <= n; s++){
      |                         ^