답안 #349567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349567 2021-01-17T20:29:01 Z blue 기지국 (IOI20_stations) C++17
0 / 100
5 ms 620 KB
#include "stations.h"
#include <iostream>
#include <vector>
using namespace std;

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

int dfs(int u, int a, bool flag) //vertex, minimum label, left/right?     return largest unused label
{
    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 j = 0; j < n-1; j++)
    {
        edge[u[j]].push_back(v[j]);
        edge[v[j]].push_back(u[j]);
    }

    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
    {
        if(t < s) return c[c.size()-1];
        for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
    }
    else // s is right label
    {
        if(t > s) return c[0];
        for(int i = c.size()-1; i >= 0; i--) if(t >= c[i]) return c[i];
    }

    return 1e9;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:55:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
      |                        ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 620 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 492 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -