답안 #321916

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321916 2020-11-13T13:58:35 Z demetre 기지국 (IOI20_stations) C++14
0 / 100
1318 ms 2097156 KB
#include "stations.h"
#include<bits/stdc++.h>

using namespace std;

int fix[10001],timer;
vector <int> v[10001];
vector <int> labels;

void dfs(int u,int d){
	fix[u]=1;
	if(d%2==0){
		timer++;
		labels[u]=timer;
	}
	for(int i = 0; i < v[u].size(); i++){
		if(fix[v[u][i]]!=0)
			dfs(v[u][i],d+1);
	}
	if(d%2!=0){
		timer++;
		labels[u]=timer;
	}
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> g) {
	labels.clear();
	labels.resize(n);
	for(int i = 0; i < n; i++){
		v[i].clear();
		fix[i]=0;
	}
	for (int i = 0; i < u.size(); i++) {
		v[u[i]].push_back(g[i]);
		v[g[i]].push_back(u[i]);
	} 
	timer=0;
	for(int i = 0; i < n; i++){
		if(fix[i]==0)
			dfs(i,0);
	}
	return labels;
}
 
int find_next_station(int s, int t, vector<int> k) {
	if(s < k[0]) {
	    if(t>s){	
			for(int i=0;i<k.size()-1;i++){
				if(t<=k[i])
					 return k[i];
			}
		}
		return k[k.size()-1];			
	}
	else {
		if(t<s){
			for(int i=k.size()-1;i>=1;i--)
			if(t>=k[i]) 
				return k[i];
		}
		return k[0];
	}
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 0; i < v[u].size(); i++){
      |                 ~~^~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 0; i < u.size(); i++) {
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:48:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    for(int i=0;i<k.size()-1;i++){
      |                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1295 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1318 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1308 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1306 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1305 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -