Submission #517049

# Submission time Handle Problem Language Result Execution time Memory
517049 2022-01-22T12:44:12 Z Ai7081 Stations (IOI20_stations) C++17
0 / 100
2257 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) {
    for (int i=0; i<u.size(); 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) {
            ret.assign(n, 0);
            cnt = 0;
            dfs1(i, i);
            return ret;
        }
    }
    return ret;
}

int find_next_station(int s, int t, vector<int> c) {
    return (s < t) ? s+1 : s-1;
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i=0; i<u.size(); i++) {
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 320 KB Invalid length of array as the response of 'label'. scenario=1, n=3, len=10
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Invalid length of array as the response of 'label'. scenario=1, n=994, len=996
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1296 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 641 ms 488 KB Output is correct
2 Incorrect 675 ms 400 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2257 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -