답안 #341670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341670 2020-12-30T12:04:14 Z ogibogi2004 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
#define time afds
const int MAXN=1024;
vector<int>g[MAXN];
int in_time[MAXN],out_time[MAXN],time=-1;
void dfs(int u,int par)
{
	in_time[u]=++time;
	for(auto v:g[u])
	{
		if(v==par)continue;
		dfs(v,u);
	}
	out_time[u]=time;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
	for(int i=0;i<u.size();i++)
	{
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	dfs(0,-1);
	for (int i = 0; i < n; i++) {
		labels[i] = in_time[i]*MAXN+out_time[i];
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	int in_s=s/MAXN,out_s=s%MAXN;
	int in_t=t/MAXN,out_t=t%MAXN;
	if(out_t<in_s||in_t>out_s)
	{
		for(auto xd:c)
		{
			int in1=xd/MAXN,out1=xd%MAXN;
			if(in1<=in_s&&out1>=out_s)
			{
				return xd;
			}
		}
	}
	else
	{
		for(auto xd:c)
		{
			int in1=xd/MAXN,out1=xd%MAXN;
			if(in1<=in_t&&out1>=out_t)
			{
				return xd;
			}
		}
	}
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:21:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=0;i<u.size();i++)
      |              ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1889 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3036 ms 612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1628 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 859 ms 864 KB Output is correct
2 Runtime error 1269 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2935 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -