제출 #696717

#제출 시각아이디문제언어결과실행 시간메모리
696717garam1732기지국 (IOI20_stations)C++14
0 / 100
1989 ms2097152 KiB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> adj[1010];
int cnt = 0;

void dfs(int here, int par, vector<int>& v) {
    for(int there : adj[here]) {
        if(there == par) continue;
        dfs(there, here, v);
    }
    v[here] = cnt++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);

	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, i, labels);
            return labels;
        }
	}
}

int find_next_station(int s, int t, std::vector<int> c) {
	if((t-s)*(c[0]-s)>=0) return c[0];
	return c[1];
}

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for(int i = 0; i < u.size(); i++) {
      |                 ~~^~~~~~~~~~
stations.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...