답안 #1095427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095427 2024-10-02T07:35:52 Z dosts 기지국 (IOI20_stations) C++17
0 / 100
3000 ms 2097152 KB
//Dost SEFEROĞLU
#include <bits/stdc++.h>
#include "stations.h"
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
//#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int N = 1000;

vi edges[N];
vi ls(N),tin(N),tout(N);
int timer = 1;
void dfs(int node,int p,int deppy = 0) {
	tin[node] = timer++;
	for (auto it : edges[node]) if (it != p) dfs(it,node,deppy^1);
	tout[node] = timer++;
	if (deppy) ls[node] = tout[node];
	else ls[node] = tin[node];
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	vi labels(n);
	for (int i=0;i<n-1;i++) {
		edges[u[i]].push_back(v[i]);
		edges[v[i]].push_back(u[i]);
	}
	dfs(0,0);
	for (int i=0;i<n;i++) labels[i] = ls[i];
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	bool ins = 0;
	if (c[0] > s) ins = 1;
	if (ins) {
		//tin bu
		int mx = 0;
		//mx parentim
		sort(all(c));
		if (s != 1) mx = c.back();
		int prv = s;
		for (auto it : c) {
			if (it == mx) return it;
			int onuntini = prv+1;
			prv = it;
			if (onuntini <= t && it >= t) return it;
		}
		return -1;
	}
	else {
		//tout bu
		sort(all(c),greater<int>());
		int mn = c.back();
		int prv = s+1;
		for (auto it : c) {
			if (it == mn) return it;
			int onuntoutu = prv-1;
			prv = it;
			if (onuntoutu >= t && it <= t) return it;
		}
		return -1;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1375 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3037 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1188 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 655 ms 688 KB Output is correct
2 Runtime error 1074 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1817 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -