Submission #305993

# Submission time Handle Problem Language Result Execution time Memory
305993 2020-09-24T09:07:43 Z llaki Stations (IOI20_stations) Java 11
0 / 100
3000 ms 21792 KB
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

Note: stations.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
# Verdict Execution time Memory Grader output
1 Execution timed out 3007 ms 21792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3083 ms 20996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3077 ms 18700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3006 ms 18584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3007 ms 18208 KB Time limit exceeded
2 Halted 0 ms 0 KB -