Submission #1095434

# Submission time Handle Problem Language Result Execution time Memory
1095434 2024-10-02T07:45:29 Z dosts Stations (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 (int 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
		if (s != 1) mx = c.back();
		int prv = s;
		for (int 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
		reverse(all(c));
		int mn = c.back();
		int prv = s+1;
		for (int it : c) {
			if (it == mn) return it;
			int onuntoutu = prv-1;
			prv = it;
			if (onuntoutu >= t && it <= t) return it;
		}
		return -1;
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 1213 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1173 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 566 ms 684 KB Output is correct
2 Runtime error 1012 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1777 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -