Submission #305993

#TimeUsernameProblemLanguageResultExecution timeMemory
305993llakiStations (IOI20_stations)Java
0 / 100
3083 ms21792 KiB
import java.util.ArrayList; public class stations { int[] label(int n, int k, int[] u, int[] v) { ArrayList<Integer>[] G = new ArrayList[n]; for (int i = 0; i < G.length; i++) { G[i] = new ArrayList<>(); } for (int i = 0; i < u.length; i++) { G[u[i]].add(v[i]); G[v[i]].add(u[i]); } int leaf = -1; for (int i = 0; i < n; i++) { if (G[i].size() == 1) { leaf = i; break; } } int[] labels = new int[n]; int cur = 0; int node = leaf; int prev = -1; while (true) { labels[node] = cur; cur++; boolean found = false; for (int to : G[node]) { if (to == prev) continue; node = to; found = true; break; } if (!found) break; } return labels; } int find_next_station(int s, int t, int[] c) { for (int nd : c) { if (s <= nd && nd <= t) return t; if (s >= nd && nd >= t) return t; } return -1; } }

Compilation message (stderr)

Note: stations.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...