답안 #431952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431952 2021-06-17T17:38:48 Z MeGustaElArroz23 기지국 (IOI20_stations) C++14
8 / 100
936 ms 532 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) {

	vi res(n);
	for (int i=0;i<n;i++) res[i]=i;
	return res;

	//cerr<<"h";
	res=vi(n);
	conexiones=vvi(n);
	cerr<<0;
	for (int i=0;i<n-1;i++){
		conexiones[u[i]].push_back(v[i]);
		conexiones[v[i]].push_back(u[i]);
	}
	cerr<<0;
	int i=0;
	while (conexiones[i].size()==2) i++;
	cerr<<0;
	int ant=-1;
	for (int j=0;j<n;j++){
		res[i]=j;
		swap(i,ant);
		for (int x:conexiones[ant]){
			if (x!=i){
				i=x;
				break;
			}
		}
	}

	return res;

	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) {

	while (true){
		if (obj==2*ac+1) return obj;
		if (obj==2*ac+2) return obj;
		if (obj<ac) return (ac-1)/2;
		obj=(obj-1)/2;
	}


	if (obj>ac) return ac+1;
	else return ac-1;


	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[0]; //arriba
	}
}


# 결과 실행 시간 메모리 Grader output
1 Incorrect 534 ms 400 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 488 ms 496 KB Output is correct
2 Correct 534 ms 532 KB Output is correct
3 Correct 862 ms 400 KB Output is correct
4 Correct 682 ms 484 KB Output is correct
5 Correct 628 ms 400 KB Output is correct
6 Correct 466 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 525 ms 400 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 936 ms 404 KB Output is correct
2 Incorrect 595 ms 528 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 526 ms 400 KB Wrong query response.
2 Halted 0 ms 0 KB -