답안 #347253

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

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

int dfs(int u, int a, bool flag) //return 1 + largest label yet created
{
    visit[u] = 1;
    cout << "dfs " << u << ' ' << a << ' ' << flag << '\n';
    if(flag == 0)
    {
        res[u] = a;
        a++;
    }

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

    if(flag == 1)
    {
        res[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]);
    }


    res = vector<int>(n, -1);
    dfs(0, 0, 0);

    return res;
}

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

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];
      |                        ~~^~~~~~~~~~
stations.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -