Submission #314055

# Submission time Handle Problem Language Result Execution time Memory
314055 2020-10-18T02:08:53 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[10000];
int lbl[1000], cnt;
void dfs(int i, int p) {
	lbl[i] = cnt++;
	for(int a: adj[i]) {
		if(a == p) continue;
		dfs(a, i);
	}
}
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++) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	for(int i=0; i<n; i++) {
		if(adj[i].size() == 1) {
			dfs(i, -1);
			break;
		}
	}
	for(int i=0; i<n; i++) {
		labels[i] = lbl[i];
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	sort(c.begin(), c.end());
	if(t > s) {
		return c.back();
	} else {
		return c.front();
	}
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:15:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0; i<u.size(); i++) {
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1663 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 3042 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1651 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 868 ms 1304 KB Output is correct
2 Incorrect 721 ms 1152 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2790 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -