Submission #313985

# Submission time Handle Problem Language Result Execution time Memory
313985 2020-10-17T17:20:34 Z dlwocks31 Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000];
int lbl[1000], cnt;
void dfs(int i, int p, int d) {
	if(d % 2 == 0)
		lbl[i] = cnt++;
	for(int a: adj[i]) {
		if(a == p) continue;
		dfs(a, i, d+1);
	}
	if(d % 2 == 1)
		lbl[i] = cnt++;
}
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++) {
		//printf("edge = %d, %d\n", u[i], v[i]);
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	dfs(0, -1, 0);
	for(int i=0; i<n; i++) {
		//printf("label %d = %d\n", i, lbl[i]);
		labels[i] = lbl[i];
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	if(c[0] > s) { // s is out
		reverse(c.begin(), c.end());
	}
	c.insert(c.begin(), s);
	for(int i=1; i<c.size(); i++) {
		if(c[i-1] <= t && t <= c[i]) {
			return c[i];
		}
	}
	return c.back();
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:18:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0; i<u.size(); i++) {
      |               ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i=1; i<c.size(); i++) {
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1559 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 Execution timed out 3067 ms 628 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1490 ms 2097152 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 913 ms 876 KB Output is correct
2 Runtime error 1256 ms 2097156 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 2404 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -