답안 #431391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431391 2021-06-17T11:35:33 Z idk321 기지국 (IOI20_stations) C++17
8 / 100
954 ms 580 KB
#include "stations.h"
#include <vector>

using namespace std;

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

int n, k;

int timer;



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.assign(n, 0);


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






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



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

    vector<int> path;
    path.push_back(t);
    while (true)
    {
        if (t == 0) break;
        t--;
        t /= 2;
        path.push_back(t);
    }

    bool contain = false;
    for (int i : path)
    {
        if (i == s) contain = true;
    }

    if (!contain) return (s - 1) / 2;

    for (int i : path)
    {
        for (int j : c)
        {
            if (j == (s - 1) / 2) continue;
            if (j == i) return i;
        }
    }

	return c[0];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i = 0; i < u.size(); i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 560 ms 500 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 542 ms 480 KB Output is correct
2 Correct 493 ms 488 KB Output is correct
3 Correct 893 ms 480 KB Output is correct
4 Correct 711 ms 580 KB Output is correct
5 Correct 621 ms 400 KB Output is correct
6 Correct 508 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 666 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 954 ms 400 KB Output is correct
2 Incorrect 730 ms 400 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 559 ms 500 KB Wrong query response.
2 Halted 0 ms 0 KB -