Submission #428505

# Submission time Handle Problem Language Result Execution time Memory
428505 2021-06-15T12:24:27 Z egekabas Stations (IOI20_stations) C++14
0 / 100
1212 ms 652 KB
#include "stations.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
vector<int> g[1009];
vector<int> ans;
int curt = 0;
void dfs(int v, int prt, int depth){
	if(depth%2 == 0)
		ans[v] = curt++;
	for(auto u : g[v])
		if(u != prt)
			dfs(u, v, depth+1);
	if(depth%2 == 1)
		ans[v] = curt++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	ans = vector<int>(n);
	for(int i = 0; i < n; ++i)
		g[i].clear();
	for(int i = 0; i < n-1; ++i){
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
	}
	curt = 0;
	dfs(0, -1, 0);
	return ans;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int smaller = 0;
	for(auto u : c)
		if(u < s)
			smaller = 1;
	if(smaller == 0){
		sort(all(c));
		for(auto u : c)
			if(t <= u)
				return u;
		return c.back();
	}
	else{
		
		sort(all(c), greater<int>());
		if(t > s)
			return c.back();
		for(auto u : c)
			if(t >= u)
				return u;
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 985 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 604 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 706 ms 652 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1212 ms 508 KB Output is correct
2 Correct 785 ms 512 KB Output is correct
3 Incorrect 744 ms 488 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 726 ms 616 KB Wrong query response.
2 Halted 0 ms 0 KB -