답안 #432611

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


using namespace std;

const int MAXN = 1000 + 23;

vector<int> g[MAXN];
vector<int> labels;
int cnt = 0;

void dfs(int v, int p = -1) {
	labels[v] = cnt++;
	for (auto i : g[v]) if (i != p) dfs(i, v);
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	for (int i = 0; i < n; i++) labels.push_back(0);
	for (int i = 0; i < n - 1; i++) {
		g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]);
	}
	for (int i = 0; i < n; i++) if (g[i].size() == 1) {
		dfs(i);
		break;
	}
	assert(labels.size() == n);
	return labels;
}

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

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from stations.cpp:2:
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:27:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |  assert(labels.size() == n);
      |         ~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 436 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 556 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1689 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2780 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -