답안 #1067575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067575 2024-08-20T20:33:44 Z guanex 기지국 (IOI20_stations) C++14
5 / 100
664 ms 832 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
    int ed[n];
    vector<vector<int>> x(n);
    for(int i = 0; i < n-1; ++i){
        labels[i] = -1;
        x[u[i]].push_back(v[i]);
        x[v[i]].push_back(u[i]);
    }
    labels[n-1] = -1;
    int root = 0;
    for(int i = 0; i < n; ++i){
        if((int)x[i].size() == 1){
            root = i;
            break;
        }
    }
    queue<int> q;
    q.push(root);
    labels[root] = 0;
    int num = 0;
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(auto e:x[p]){
            if(labels[e] != -1){
                continue;
            }else{
                q.push(e);
                labels[e] = ++num;
            }
        }
    }
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s > t){
        return s-1;
	}else{
        return s+1;
	}
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:8:9: warning: unused variable 'ed' [-Wunused-variable]
    8 |     int ed[n];
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 359 ms 684 KB Output is correct
2 Correct 278 ms 684 KB Output is correct
3 Correct 633 ms 684 KB Output is correct
4 Correct 448 ms 684 KB Output is correct
5 Correct 412 ms 684 KB Output is correct
6 Correct 321 ms 684 KB Output is correct
7 Correct 277 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 776 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 290 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 405 ms 684 KB Output is correct
2 Correct 282 ms 684 KB Output is correct
3 Correct 609 ms 684 KB Output is correct
4 Correct 473 ms 684 KB Output is correct
5 Correct 437 ms 684 KB Output is correct
6 Correct 329 ms 684 KB Output is correct
7 Correct 313 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 2 ms 832 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 426 ms 684 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 594 ms 684 KB Output is correct
2 Correct 497 ms 684 KB Output is correct
3 Correct 424 ms 684 KB Output is correct
4 Correct 1 ms 776 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 0 ms 776 KB Output is correct
7 Incorrect 420 ms 684 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 383 ms 692 KB Output is correct
2 Correct 309 ms 716 KB Output is correct
3 Correct 664 ms 684 KB Output is correct
4 Correct 460 ms 684 KB Output is correct
5 Correct 396 ms 684 KB Output is correct
6 Correct 327 ms 688 KB Output is correct
7 Correct 287 ms 684 KB Output is correct
8 Correct 1 ms 760 KB Output is correct
9 Correct 1 ms 764 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 292 ms 688 KB Wrong query response.
12 Halted 0 ms 0 KB -