private void FillVoxelPoint(Point3D voxelPoint) { var bot = _scene.GetFirstBot(); var botVector = Vector3D.FromPoint(bot.Current); var voxelVector = Vector3D.FromPoint(voxelPoint); var dsuIndex = GetPointDSUIndex(voxelPoint); if (voxelPoint.Y == 0) { // foreach (var point in FilledAdjacent(voxelPoint)) // { // var p = GetPointDSUIndex(point); // _dsu.Union(p, dsuIndex); // } _dsu.Union(0, dsuIndex); } else { var adjacentFilled = FilledAdjacent(voxelPoint).ToList(); if (adjacentFilled.Count > 0) { foreach (var point in adjacentFilled) { var p = GetPointDSUIndex(point); _dsu.Union(p, dsuIndex); } } else { if (_scene.SceneState.HarmonicsMode == HarmonicsMode.Grounded) { ApplyCommand(new FlipCommand()); } } } _voxelsFilled += 1; ApplyCommand(new FillCommand(voxelVector - botVector)); if (_voxelsFilled == _dsu.SizeOf(0) - 2) { if (_scene.SceneState.HarmonicsMode == HarmonicsMode.Floating) { ApplyCommand(new FlipCommand()); } } else { if (_scene.SceneState.HarmonicsMode == HarmonicsMode.Grounded) { ApplyCommand(new FlipCommand()); } } }
public static void Solve() { var(N, M, K) = Scanner.Scan <int, int, int>(); var friends = new List <int> [N].Select(x => new List <int>()).ToArray(); var blocks = new List <int> [N].Select(x => new List <int>()).ToArray(); var dsu = new DSU(N); for (var i = 0; i < M; i++) { var(A, B) = Scanner.Scan <int, int>(); dsu.Merge(--A, --B); friends[A].Add(B); friends[B].Add(A); } for (var i = 0; i < K; i++) { var(C, D) = Scanner.Scan <int, int>(); blocks[--C].Add(--D); blocks[D].Add(C); } var answer = new int[N]; for (var i = 0; i < N; i++) { answer[i] = dsu.SizeOf(i) - friends[i].Count - 1; foreach (var block in blocks[i]) { if (dsu.IsSame(i, block)) { answer[i]--; } } } Console.WriteLine(string.Join(" ", answer)); }