Submission #430495

# Submission time Handle Problem Language Result Execution time Memory
430495 2021-06-16T14:41:22 Z alishahali1382 Stations (IOI20_stations) C++14
76 / 100
1718 ms 860 KB
#include "stations.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": "; for (auto dcba:abcd) cerr<<dcba<<", ";cerr<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())

const int inf=1000000100; // 1e9
const ll INF=10000000001000000; // 1e16
const int mod=1000000007;
const int MAXN=1010;

int n, m, k, x, y, a, b, t, ans;
int stt[MAXN], fnt[MAXN], h[MAXN], timer;
vi G[MAXN];

void dfs(int node, int par){
	stt[node]=timer++;
	for (int v:G[node]) if (v!=par){
		h[v]=h[node]+1;
		dfs(v, node);
	}
	fnt[node]=timer++;
}

vi label(int _n, int _k, vi U, vi V){
	n=_n;
	k=_k;
	vi out(n);
	for (int i=0; i<n; i++) G[i].clear();
	for (int i=0; i<n-1; i++){
		int u=U[i], v=V[i];
		G[u].pb(v);
		G[v].pb(u);
	}
	timer=0;
	dfs(0, 0);
	for (int i=0; i<n; i++){
		if (h[i]&1) out[i]=fnt[i];
		else out[i]=stt[i];
	}
	vi comp=out;
	sort(all(comp));
	// for (int i=0; i<n; i++) out[i]=lower_bound(all(comp), out[i])-comp.begin();
	return out;
}

int find_next_station(int s, int t, vi adj){
	// cerr<<"\n";
	// debug2(s, t)
	for (int x:adj) if (x==t) return x;
	if (SZ(adj)==1) return adj[0];
	sort(all(adj));
	if (s<adj[0]){
		// stt
		int par=-1;
		if (s){
			par=adj.back();
			adj.pop_back();
		}
		int stt_s=s, fnt_s=adj.back();
		if (t<stt_s || fnt_s<t) return par;
		return *lower_bound(all(adj), t);
	}
	// fnt
	assert(adj.back()<s);
	int par=adj[0];
	reverse(all(adj));
	adj.pop_back();
	
	int stt_s=adj.back(), fnt_s=s;
	if (t<stt_s || fnt_s<t) return par;
	while (SZ(adj)>1){
		int v=adj.back();
		adj.pop_back();
		if (adj.back()<t) continue ;
		return v;
	}
	return adj.back();
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 432 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 292 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 928 ms 620 KB Output is correct
2 Correct 554 ms 528 KB Output is correct
3 Correct 1230 ms 488 KB Output is correct
4 Correct 862 ms 512 KB Output is correct
5 Correct 823 ms 492 KB Output is correct
6 Correct 672 ms 520 KB Output is correct
7 Correct 553 ms 508 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 6 ms 596 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 734 ms 568 KB Output is correct
12 Correct 707 ms 860 KB Output is correct
13 Correct 618 ms 708 KB Output is correct
14 Correct 576 ms 528 KB Output is correct
15 Correct 68 ms 528 KB Output is correct
16 Correct 92 ms 656 KB Output is correct
17 Correct 106 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1020 ms 400 KB Output is correct
2 Correct 1160 ms 508 KB Output is correct
3 Correct 697 ms 504 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 4 ms 588 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 901 ms 500 KB Output is correct
8 Correct 1718 ms 504 KB Output is correct
9 Correct 870 ms 516 KB Output is correct
10 Correct 741 ms 400 KB Output is correct
11 Correct 9 ms 548 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
13 Correct 7 ms 596 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 720 ms 516 KB Output is correct
17 Correct 1156 ms 528 KB Output is correct
18 Correct 667 ms 508 KB Output is correct
19 Correct 644 ms 508 KB Output is correct
20 Correct 645 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 593 ms 616 KB Partially correct
2 Partially correct 644 ms 612 KB Partially correct
3 Correct 1331 ms 512 KB Output is correct
4 Correct 1000 ms 508 KB Output is correct
5 Correct 745 ms 556 KB Output is correct
6 Partially correct 689 ms 624 KB Partially correct
7 Partially correct 824 ms 504 KB Partially correct
8 Correct 3 ms 776 KB Output is correct
9 Correct 4 ms 528 KB Output is correct
10 Correct 2 ms 808 KB Output is correct
11 Partially correct 692 ms 560 KB Partially correct
12 Partially correct 1057 ms 516 KB Partially correct
13 Correct 1285 ms 672 KB Output is correct
14 Correct 833 ms 492 KB Output is correct
15 Correct 956 ms 564 KB Output is correct
16 Partially correct 796 ms 516 KB Partially correct
17 Correct 1093 ms 784 KB Output is correct
18 Partially correct 549 ms 708 KB Partially correct
19 Partially correct 527 ms 748 KB Partially correct
20 Partially correct 583 ms 520 KB Partially correct
21 Correct 89 ms 528 KB Output is correct
22 Partially correct 87 ms 528 KB Partially correct
23 Partially correct 130 ms 720 KB Partially correct
24 Correct 8 ms 716 KB Output is correct
25 Correct 4 ms 468 KB Output is correct
26 Correct 6 ms 600 KB Output is correct
27 Correct 6 ms 676 KB Output is correct
28 Correct 2 ms 716 KB Output is correct
29 Correct 764 ms 508 KB Output is correct
30 Correct 728 ms 528 KB Output is correct
31 Correct 708 ms 496 KB Output is correct
32 Correct 690 ms 516 KB Output is correct
33 Correct 664 ms 568 KB Output is correct
34 Partially correct 590 ms 692 KB Partially correct
35 Partially correct 744 ms 840 KB Partially correct
36 Partially correct 578 ms 760 KB Partially correct
37 Partially correct 538 ms 816 KB Partially correct
38 Partially correct 586 ms 704 KB Partially correct
39 Partially correct 747 ms 712 KB Partially correct
40 Partially correct 470 ms 788 KB Partially correct
41 Partially correct 838 ms 792 KB Partially correct
42 Partially correct 75 ms 656 KB Partially correct
43 Partially correct 177 ms 656 KB Partially correct
44 Partially correct 125 ms 716 KB Partially correct
45 Partially correct 278 ms 596 KB Partially correct
46 Partially correct 465 ms 528 KB Partially correct
47 Partially correct 457 ms 620 KB Partially correct
48 Partially correct 158 ms 656 KB Partially correct
49 Partially correct 92 ms 784 KB Partially correct