답안 #1095710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095710 2024-10-03T02:55:41 Z Newtonabc 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 2097152 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int tmpcase1,cnt=0;
vector<int> adj[N],lb;
void labelcase1(int u,int p){
	lb[u]=cnt++;
	for(int i=0;i<adj[u].size();i++){
		if(adj[u][i]!=p) labelcase1(adj[u][i],u);
	}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	lb.resize(n);
	for(int i=0;i<n-1;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) tmpcase1=i;
	}
	
	labelcase1(tmpcase1,-1);
	
	/*for(int i=0;i<lb.size();i++) cout<<lb[i] <<" ";
	cout<<"\n\n\n";*/
	return lb;
}

int find_next_station(int s, int t, vector<int> c) {
	if(c.size()==1) return c[0];
	sort(c.begin(),c.end());
	if(s<t) return c[1];
	return c[0];
}

Compilation message

stations.cpp: In function 'void labelcase1(int, int)':
stations.cpp:9:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0;i<adj[u].size();i++){
      |              ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1355 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3061 ms 528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1439 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 611 ms 684 KB Output is correct
2 Runtime error 1194 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2223 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -