답안 #431395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431395 2021-06-17T11:37:52 Z idk321 기지국 (IOI20_stations) C++17
5 / 100
931 ms 608 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;
}

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



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++)
    {
        if (adj[i].size() == 1)
        {
            dfs(i, -1, 0);
            break;
        }
    }



	return labels;
}



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

    if (s < t)
    {
        for (int j : c)
        {
            if (j > s) return j;
        }
    } else
    {
        for (int j : c)
        {
            if (j < s) return j;
        }
    }

	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 Correct 519 ms 604 KB Output is correct
2 Correct 460 ms 488 KB Output is correct
3 Correct 916 ms 488 KB Output is correct
4 Correct 676 ms 464 KB Output is correct
5 Correct 627 ms 400 KB Output is correct
6 Correct 458 ms 524 KB Output is correct
7 Correct 418 ms 528 KB Output is correct
8 Correct 3 ms 488 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 292 KB Invalid labels (duplicates values). scenario=0, label=10
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 582 ms 556 KB Output is correct
2 Correct 502 ms 488 KB Output is correct
3 Correct 899 ms 400 KB Output is correct
4 Correct 826 ms 400 KB Output is correct
5 Correct 578 ms 500 KB Output is correct
6 Correct 479 ms 568 KB Output is correct
7 Correct 483 ms 504 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Incorrect 1 ms 284 KB Invalid labels (duplicates values). scenario=1, label=2
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 931 ms 480 KB Output is correct
2 Correct 672 ms 400 KB Output is correct
3 Correct 590 ms 500 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Incorrect 1 ms 300 KB Invalid labels (duplicates values). scenario=0, label=2
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 569 ms 528 KB Output is correct
2 Correct 422 ms 492 KB Output is correct
3 Correct 899 ms 528 KB Output is correct
4 Correct 640 ms 400 KB Output is correct
5 Correct 610 ms 400 KB Output is correct
6 Correct 471 ms 488 KB Output is correct
7 Correct 466 ms 528 KB Output is correct
8 Correct 2 ms 540 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Incorrect 5 ms 300 KB Invalid labels (duplicates values). scenario=0, label=10
12 Halted 0 ms 0 KB -