Submission #349569

# Submission time Handle Problem Language Result Execution time Memory
349569 2021-01-17T20:45:03 Z blue Stations (IOI20_stations) C++17
0 / 100
5 ms 752 KB
#include "stations.h"
#include <vector>
using namespace std;

vector<int> visit(1000, 0);
vector<int> edge[1000];
vector<int> L;

int dfs(int u, int a, bool flag)
{
    visit[u] = 1;

    if(flag == 0)
    {
        L[u] = a;
        a++;
    }

    for(int v: edge[u])
    {
        if(visit[v]) continue;
        a = dfs(v, a, !flag);
    }

    if(flag == 1)
    {
        L[u] = a;
        a++;
    }

    return a;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
    for(int i = 0; i < n-1; i++)
    {
        edge[u[i]].push_back(v[i]);
        edge[v[i]].push_back(u[i]);
    }

    L = vector<int>(n, -1);

    dfs(0, 0, 0);

    return L;
}

int find_next_station(int s, int t, vector<int> c)
{
    if(s < c[0]) //s is left label
    {
        for(int i = 0; i < c.size(); i++)
        {
            if(t <= c[i]) return c[i];
        }
        return c[c.size() - 1];
    }
    else //s is right label
    {
        for(int i = c.size() - 1; i >= 0; i--)
        {
            if(t >= c[i]) return c[i];
        }
        return c[0];
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:53:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int i = 0; i < c.size(); i++)
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 752 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 492 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=-1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-1
2 Halted 0 ms 0 KB -