Submission #342380

# Submission time Handle Problem Language Result Execution time Memory
342380 2021-01-02T03:19:10 Z Ta180m Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MX = 1e5+5;

int cnt = 1;
vector<int> labels, G[MX];

void dfs(int u, int p) {
	for (int v : G[u]) if (v != p) dfs(v, u);
	labels[u] = cnt++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	for (int i = 0; i < n-1; ++i) {
		G[u[i]].push_back(v[i]);
		G[v[i]].push_back(u[i]);
	}
	labels.resize(n);
	dfs(0, -1);
	// for (int x : labels) cout << x << '\n';
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if (t <= c[0]) return c[0];
	for (int i = 1; i < c.size(); ++i) {
		if (t > c[i-1] && t <= c[i]) return c[i];
	}
	// cout << s << ' ' << t;
	// for (int x : c) cout << ' ' << x;
	// cout << '\n';
	return c.back();
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i = 1; i < c.size(); ++i) {
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3123 ms 2097156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3042 ms 2944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1620 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 846 ms 5664 KB Output is correct
2 Runtime error 1232 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2896 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -