Submission #1095443

# Submission time Handle Problem Language Result Execution time Memory
1095443 2024-10-02T08:09:47 Z dosts Stations (IOI20_stations) C++17
100 / 100
637 ms 1196 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);
	vi lss = vector<int>(ls.begin(),ls.begin()+n);
	sort(all(lss));
	for (int i=0;i<n;i++) ls[i] = upper_bound(all(lss),ls[i])-lss.begin();
	for (int i=0;i<n;i++) labels[i] = ls[i];
	timer = 1;
	for (int i=0;i<n;i++) edges[i].clear();
	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 Correct 365 ms 940 KB Output is correct
2 Correct 265 ms 940 KB Output is correct
3 Correct 583 ms 684 KB Output is correct
4 Correct 450 ms 684 KB Output is correct
5 Correct 424 ms 684 KB Output is correct
6 Correct 311 ms 940 KB Output is correct
7 Correct 301 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 308 ms 684 KB Output is correct
2 Correct 335 ms 684 KB Output is correct
3 Correct 637 ms 684 KB Output is correct
4 Correct 465 ms 688 KB Output is correct
5 Correct 397 ms 684 KB Output is correct
6 Correct 286 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 339 ms 940 KB Output is correct
2 Correct 292 ms 940 KB Output is correct
3 Correct 586 ms 684 KB Output is correct
4 Correct 470 ms 684 KB Output is correct
5 Correct 406 ms 684 KB Output is correct
6 Correct 268 ms 940 KB Output is correct
7 Correct 307 ms 688 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 0 ms 812 KB Output is correct
11 Correct 387 ms 684 KB Output is correct
12 Correct 294 ms 1064 KB Output is correct
13 Correct 274 ms 1056 KB Output is correct
14 Correct 265 ms 940 KB Output is correct
15 Correct 34 ms 764 KB Output is correct
16 Correct 34 ms 768 KB Output is correct
17 Correct 72 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 550 ms 684 KB Output is correct
2 Correct 404 ms 684 KB Output is correct
3 Correct 443 ms 684 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 2 ms 776 KB Output is correct
6 Correct 0 ms 776 KB Output is correct
7 Correct 370 ms 804 KB Output is correct
8 Correct 607 ms 684 KB Output is correct
9 Correct 417 ms 684 KB Output is correct
10 Correct 376 ms 684 KB Output is correct
11 Correct 4 ms 764 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 1 ms 776 KB Output is correct
16 Correct 315 ms 684 KB Output is correct
17 Correct 343 ms 684 KB Output is correct
18 Correct 381 ms 688 KB Output is correct
19 Correct 356 ms 684 KB Output is correct
20 Correct 350 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 349 ms 940 KB Output is correct
2 Correct 314 ms 940 KB Output is correct
3 Correct 559 ms 684 KB Output is correct
4 Correct 467 ms 684 KB Output is correct
5 Correct 369 ms 684 KB Output is correct
6 Correct 268 ms 940 KB Output is correct
7 Correct 301 ms 688 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
11 Correct 274 ms 684 KB Output is correct
12 Correct 363 ms 684 KB Output is correct
13 Correct 570 ms 684 KB Output is correct
14 Correct 468 ms 688 KB Output is correct
15 Correct 415 ms 684 KB Output is correct
16 Correct 312 ms 684 KB Output is correct
17 Correct 407 ms 684 KB Output is correct
18 Correct 331 ms 804 KB Output is correct
19 Correct 282 ms 1048 KB Output is correct
20 Correct 299 ms 684 KB Output is correct
21 Correct 33 ms 764 KB Output is correct
22 Correct 37 ms 716 KB Output is correct
23 Correct 65 ms 744 KB Output is correct
24 Correct 3 ms 776 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 1 ms 768 KB Output is correct
27 Correct 1 ms 768 KB Output is correct
28 Correct 0 ms 768 KB Output is correct
29 Correct 321 ms 684 KB Output is correct
30 Correct 344 ms 684 KB Output is correct
31 Correct 370 ms 684 KB Output is correct
32 Correct 351 ms 684 KB Output is correct
33 Correct 360 ms 684 KB Output is correct
34 Correct 180 ms 684 KB Output is correct
35 Correct 258 ms 940 KB Output is correct
36 Correct 293 ms 808 KB Output is correct
37 Correct 315 ms 936 KB Output is correct
38 Correct 318 ms 1048 KB Output is correct
39 Correct 331 ms 940 KB Output is correct
40 Correct 278 ms 684 KB Output is correct
41 Correct 314 ms 800 KB Output is correct
42 Correct 40 ms 768 KB Output is correct
43 Correct 78 ms 744 KB Output is correct
44 Correct 68 ms 684 KB Output is correct
45 Correct 101 ms 684 KB Output is correct
46 Correct 190 ms 684 KB Output is correct
47 Correct 210 ms 684 KB Output is correct
48 Correct 28 ms 768 KB Output is correct
49 Correct 37 ms 1196 KB Output is correct