Skip to content

Commit

Permalink
20240604 cc4414's submission for CF1133F2 (Yawn-Sean#3183)
Browse files Browse the repository at this point in the history
* 20240227 cc4414's submission

* Create cf1260c_cc4414.java

20240228 cc4414's submission for CF1260C

* 20240228 cc4414's submission for CF1152D

* 20240229 cc4414's submission for 1512G

* 20240229 cc4414's submission for CF258C

* 20240301 cc4414's submission for 687A

* 20240301 cc4414's submission for 1498E

* 20240302 cc4414's submission for CF1936C

* Create cf749d_cc4414.java

20240424 cc4414's submission for CF749D

* 20240508 cc4414's submission for CF721D

* 20240511 cc4414's submission for CF852F

* 20240513 cc4414's submission for CF799C

* 20240513 cc4414's submission for CF1029D

* 20240514 cc4414's submission for CF965D

* 20240514 cc4414's submission for CF914C

* 20240518 cc4414's submission for CF1056D

* 20240524 cc4414's submission for CF301B

* 20240604 cc4414's submission for CF1133F2

* 20240604 cc4414's submission for CF1949I
  • Loading branch information
cc4414 authored Jun 4, 2024
1 parent c239dc1 commit 6441b1d
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Submission link: https://codeforces.com/contest/1133/submission/264089918
class Solution {
public List<int[]> solve(int[][] edges, int n, int d) {
List<int[]> list = new ArrayList<>();
Set<Integer>[] sets = new Set[n];
for (int i = 0; i < n; i++) {
sets[i] = new HashSet<>();
}
for (int[] edge : edges) {
sets[edge[0]].add(edge[1]);
sets[edge[1]].add(edge[0]);
}
if (sets[0].size() < d) {
return null;
}
UnionFind unionFind = new UnionFind(n);
for (int[] edge : edges) {
if (edge[0] != 0 && edge[1] != 0) {
unionFind.union(edge[0], edge[1]);
}
}
int t = unionFind.size - 1;
if (d < t) {
return null;
}
t = d;
boolean[] vis = new boolean[n];
vis[0] = true;
ArrayDeque<Integer> deque = new ArrayDeque<>();
for (Integer v : sets[0]) {
if (unionFind.isUnion(0, v)) {
continue;
}
unionFind.union(0, v);
list.add(new int[]{0, v});
deque.add(v);
vis[v] = true;
t--;
}
for (Integer v : sets[0]) {
if (t == 0) {
break;
}
if (vis[v]) {
continue;
}
list.add(new int[]{0, v});
deque.add(v);
vis[v] = true;
t--;
}
while (!deque.isEmpty()) {
Integer remove = deque.remove();
for (Integer w : sets[remove]) {
if (vis[w]) {
continue;
}
list.add(new int[]{remove, w});
deque.add(w);
vis[w] = true;
}
}
return list;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Submission link: https://codeforces.com/contest/1949/submission/264101759
class Solution {
public boolean solve(long[][] a) {
double eps = 1e-9;
int n = a.length;
boolean[][] con = new boolean[n][n];
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
long dx = a[i][0] - a[j][0];
long dy = a[i][1] - a[j][1];
if (Math.sqrt(dx * dx + dy * dy) - a[i][2] - a[j][2] < eps) {
con[i][j] = true;
con[j][i] = true;
}
}
}
boolean[] vis = new boolean[n];
int[] color = new int[n];
for (int i = 0; i < n; i++) {
if (vis[i]) {
continue;
}
int[] cnt = new int[2];
cnt[0] = 1;
boolean b = true;
ArrayDeque<Integer> deque = new ArrayDeque<>();
deque.add(i);
vis[i] = true;
while (!deque.isEmpty()) {
Integer remove = deque.remove();
for (int j = 0; j < n; j++) {
if (con[remove][j]) {
if (vis[j]) {
if (color[remove] == color[j]) {
b = false;
}
continue;
}
deque.add(j);
vis[j] = true;
color[j] = color[remove] ^ 1;
cnt[color[j]]++;
}
}
}
if (b && cnt[0] != cnt[1]) {
return true;
}
}
return false;
}
}

0 comments on commit 6441b1d

Please sign in to comment.