Submission #431917

# Submission time Handle Problem Language Result Execution time Memory
431917 2021-06-17T17:14:03 Z MeGustaElArroz23 Stations (IOI20_stations) C++14
0 / 100
897 ms 656 KB
#include "stations.h"
#include <cstdio>
#include <cassert>
#include <map>
#include <vector>
#include <algorithm>

////////
///////////////////

#include "stations.h"
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef vector<bool> vb;

int tiempo;
vvi conexiones;
vi labeles;

void bfs(int ac, int ant, bool entrada){
	
	tiempo++;
	//cerr << ac << ' ' << tiempo << '\n';
	if (entrada) labeles[ac]=tiempo;
	for (int x:conexiones[ac]){
		if (x!=ant){
			bfs(x,ac,not entrada);
		}
	}
	tiempo++;
	//cerr << ac << ' ' << tiempo << '\n';
	if (not entrada) labeles[ac]=tiempo+2000;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	//cerr<<"h";
	tiempo=-1;
	conexiones=vvi(n);
	for (int i=0;i<n-1;i++){
		conexiones[u[i]].push_back(v[i]);
		conexiones[v[i]].push_back(u[i]);
	}
	labeles=vi(n);
	bfs(0,-1, 1);
	//for (int x:labeles) cerr << x << ' ';
	//cerr<<'\n';
	return labeles;
}

int find_next_station(int ac, int obj, std::vector<int> vecinos) {
	obj%=2000;
	bool entrada=(ac<2000);
	ac%=2000;
	sort(vecinos.begin(),vecinos.end());
	if (vecinos.size()==1) return vecinos[0]; //arriba
	if (entrada){
		int izq=ac;
		if (obj<izq) return vecinos[vecinos.size()-1]; //arriba
		for (int x:vecinos){
			if (x%2000>=obj) return x; //abajo
		}
		return vecinos[vecinos.size()-1]; //arriba
	}
	else{
		int der=ac;
		if (obj>der) return vecinos[0]; //arriba
		for (int i=vecinos.size()-1;i>=0;i--){
			int x=vecinos[i];
			if (x%2000<=obj) return x; //abajo
		}
		return vecinos[vecinos.size()-1]; //arriba
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 456 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2014
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 412 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=3022
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 532 ms 656 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 897 ms 404 KB Output is correct
2 Correct 645 ms 488 KB Output is correct
3 Correct 559 ms 400 KB Output is correct
4 Correct 3 ms 476 KB Output is correct
5 Incorrect 4 ms 464 KB Wrong query response.
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 512 ms 648 KB Wrong query response.
2 Halted 0 ms 0 KB -