답안 #308263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308263 2020-09-30T16:36:34 Z Peti 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 640 KB
#include "stations.h"
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<vector<int>> g;
vector<bool> volt;

int ido = 0;
void Bejar(vector<int> &labels, int akt, int t)
{
    volt[akt] = true;

    if(t%2 == 0)
        labels[akt] = ido;
    ido++;

    for(int x : g[akt])
        if(!volt[x])
            Bejar(labels, x, t+1);

    if(t%2 == 1)
        labels[akt] = ido;
    ido++;
    return;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {

    g.resize(n);
    volt.resize(n, false);
    for(int i = 0; i < n-1; i++)
    {
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }

	std::vector<int> labels(n);
    Bejar(labels, 0, 0);

    for(int i = 0; i < n; i++)
        while(!volt[i]);

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {

    sort(c.begin(), c.end());

    if(s < c[0])
    {
        if(t < s || t > (*c.rbegin()))
            return (*c.rbegin());
        for(int x : c)
            if(x >= t)
                return x;
    }
    else
    {
        if(t > s || t <= c[0])
            return c[0];
        reverse(c.begin(), c.end());
        for(int x : c)
            if(x <= t)
                return x;
    }

	return -1;
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:43:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   43 |     for(int i = 0; i < n; i++)
      |     ^~~
stations.cpp:46:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |  return labels;
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3039 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 856 ms 640 KB Output is correct
2 Incorrect 1 ms 256 KB Invalid labels (duplicates values). scenario=1, label=0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3062 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -