Submission #306756

# Submission time Handle Problem Language Result Execution time Memory
306756 2020-09-26T08:44:54 Z VEGAnn Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
vector<int> g[1000];
int tin[1000], tout[1000], tt = 0;
int tin_s, tout_s, tin_v, tout_v, tin_t, tout_t;

void dfs(int v, int p){
    tin[v] = tt++;

    for (int u : g[v]){
        if (u == p) continue;
        dfs(u, v);
    }

    tout[v] = tt - 1;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    for (int i = 0; i < sz(u); i++){
        g[u[i]].PB(v[i]);
        g[v[i]].PB(u[i]);
    }

    dfs(0, -1);

    vector<int> labels;

    labels.resize(n);

    const int N = 1000;

    for (int i = 0; i < n; i++)
        labels[i] = tin[i] * N + tout[i];

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    const int N = 1000;

    tin_s = s / N;
    tout_s = s % N;

    tin_t = t / N;
    tout_t = t % N;

    if (tin_s <= tin_t && tout_s >= tout_t){
        for (int v : c) {
            tin_v = v / N;
            tout_v = v % N;

            if (tin_v > tin_s && tin_v <= tin_t && tout_v >= tout_t)
                return v;
        }
    } else {
        for (int v : c)
            if (v / N < tin_s)
                return v;
    }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:35:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |     for (int i = 0; i < n; i++)
      |     ^~~
stations.cpp:38:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   38 |  return labels;
      |  ^~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1477 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1700 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 897 ms 768 KB Output is correct
2 Runtime error 1271 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2994 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -