Submission #517045

# Submission time Handle Problem Language Result Execution time Memory
517045 2022-01-22T12:40:09 Z Ai7081 Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;

int cnt;
vector<int> adj[N], ret;

void dfs1(int v, int p) {
    ret[v] = cnt++;
    for (auto to : adj[v]) {
        if (to != p) {
            dfs1(to, v);
        }
    }
    return;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    int idx, p;
    for (int i=0; i<n-1; i++) {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    for (int i=0; i<n; i++) {
        if (adj[i].size() == 1) { idx = i; break; }
    }
    ret.assign(n, 0);
    cnt = 0;
    dfs1(idx, idx);
    return ret;
}

int find_next_station(int s, int t, vector<int> c) {
    return (s < t) ? s+1 : s-1;
}
/*
int main() {
    int n = 5;
    int k = 20;
    vector<int> u = {0, 1, 2, 3};
    vector<int> v = {1, 2, 3, 4};
    vector<int> out = label(n, k, u, v);
    for (auto it : out) cout << it << ' ';
    cout << find_next_station(2, 4, v);
}
*/

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:19:14: warning: unused variable 'p' [-Wunused-variable]
   19 |     int idx, p;
      |              ^
stations.cpp:29:9: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |     dfs1(idx, idx);
      |     ~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1200 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3022 ms 500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1309 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 936 ms 400 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2333 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -