답안 #307062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307062 2020-09-26T22:24:04 Z junseo 기지국 (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define rmin(r, x) r = min(r, x)
#define rmax(r, x) r = max(r, x)
#define ends ' '
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxn = 1e3 + 10;

int T;
vector<int> l, adj[maxn];

void dfs(int u, int p, bool f) {
	if(f)	l[u] = T++;
	for(auto& v : adj[u]) if(v != p) dfs(v, u, f ^ true);
	if(!f)	l[u] = T++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	l.resize(n);
	for(int i = 0; i < u.size(); ++i) {
		adj[u[i]].eb(v[i]);
		adj[v[i]].eb(u[i]);
	}
	dfs(0, -1, true);
	return l;
}

int find_next_station(int s, int t, vector<int> c) {
	int n = c.size();
	if(n == 1)	return c[0];
	if(s < c[0]) {
		if(!s && (t < s || c[n - 2] < t))	return c[n - 1];
		for(int i = 0; i < n; ++i)	if(t <= c[i])	return c[i];
	}
	else {
		if(t < c[1] || s < t)	return c[0];
		for(int i = n - 1; i >= 0; --i)	if(c[i] <= t)	return c[i];
	}
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i = 0; i < u.size(); ++i) {
      |                 ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1310 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 3038 ms 824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1405 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 890 ms 876 KB Output is correct
2 Runtime error 1171 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2269 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -