답안 #431357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431357 2021-06-17T11:20:45 Z idk321 기지국 (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <vector>

using namespace std;

const int M = 1000000000;
const int N = 1000;
int distBetween[N][N];
int in[N];
int out[N];
vector<int> adj[N];
vector<int> labels;

int n, k;

int timer;

void dfs(int node, int par, int cdist, int origin)
{
    distBetween[origin][node] = cdist;

    for (int next : adj[node])
    {
        if (next == par) continue;
        dfs(next, node, cdist + 1, origin);
    }

}

void dfs2(int node, int par)
{
    timer++;
    in[node] = timer;

    for (int next : adj[node])
    {
        if (next == par) continue;
        dfs2(next, node);
    }

    out[node] = timer;
}





std::vector<int> label(int n1, int k1, std::vector<int> u, std::vector<int> v) {
    n = n1;
    k = k1;
	labels.resize(n);

    for (int i = 0; i < u.size(); i++)
    {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }




    timer = -1;
    dfs2(0, -1);



	for (int i = 0; i < n; i++) {
		labels[i] = in[i] * 1000 + out[i];
	}
	return labels;
}



int find_next_station(int s, int t, std::vector<int> c) {
    int sIn = s / 1000;
    int sOut = s % 1000;
    int tIn = t / 1000;
    int tOut = t % 1000;


    if (sIn <= tIn && tOut <= sOut)
    {
        for (int next : c)
        {
            int nextIn = next / 1000;
            int nextOut = next % 1000;
            if (!(nextIn <= sIn && sOut <= nextOut) && (nextIn <= tIn && tOut <= nextOut)) return next;
        }
    } else
    {
        for (int next : c)
        {
            int nextIn = next / 1000;
            int nextOut = next % 1000;
            if (nextIn <= sIn && sOut <= nextOut) return next;
        }
    }



	return c[0];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:53:23: 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 < u.size(); i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2025 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3060 ms 412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1787 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1041 ms 488 KB Output is correct
2 Runtime error 1405 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3140 ms 1943816 KB Time limit exceeded
2 Halted 0 ms 0 KB -