Submission #349574

# Submission time Handle Problem Language Result Execution time Memory
349574 2021-01-17T21:04:21 Z blue Stations (IOI20_stations) C++17
0 / 100
4 ms 812 KB
 #include "stations.h"
#include <iostream>
#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)
{
    // cout << s << ' ' << t << " : ";
    // for(int I:c) cout << I << ' ';
    // cout << '\n';

    if(c.size() == 1) return c[0];

    if(s < c[0]) //s is left label
    {
        // cout << "left " << '\n';
        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
    {
        // cout << "right " << '\n';
        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:61:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int i = 0; i < c.size(); i++)
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 812 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 4 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 2 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 -