Submission #336014

# Submission time Handle Problem Language Result Execution time Memory
336014 2020-12-14T13:32:20 Z richyrich Stations (IOI20_stations) C++17
0 / 100
1015 ms 1248 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4+3;
const int inf = 1e9;
int ans[N], timer, vis[N];
vector<vector<int>> adj(N);
void dfs(int x, int par) {
    vis[x] = 1;
    for(int y : adj[x]) {
        if(y==par || vis[y]) continue;
        dfs(y, x);
    }
    ans[x] = timer++;
    return;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    timer = 0;
    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) {
            dfs(i, -1);
            break;
        }
    }
    std::vector<int> labels(n);
    for(int i = 0; i < n; i++) labels[i] = ans[i];
    return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    int n = c.size();
    if(s > t) return c[0];
    else return c[n-1];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0; i < u.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 748 KB Invalid labels (duplicates values). scenario=2, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 748 KB Invalid labels (duplicates values). scenario=3, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 748 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1015 ms 1248 KB Output is correct
2 Incorrect 734 ms 1248 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 748 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -