Submission #430480

# Submission time Handle Problem Language Result Execution time Memory
430480 2021-06-16T14:30:19 Z alishahali1382 Stations (IOI20_stations) C++14
76 / 100
1099 ms 888 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];
	}
	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()+1;
		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()-1, 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 3 ms 328 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 4 ms 300 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 632 ms 816 KB Output is correct
2 Correct 654 ms 528 KB Output is correct
3 Correct 990 ms 648 KB Output is correct
4 Correct 836 ms 500 KB Output is correct
5 Correct 826 ms 508 KB Output is correct
6 Correct 448 ms 528 KB Output is correct
7 Correct 509 ms 508 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 7 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 711 ms 400 KB Output is correct
12 Correct 513 ms 888 KB Output is correct
13 Correct 632 ms 624 KB Output is correct
14 Correct 584 ms 500 KB Output is correct
15 Correct 94 ms 728 KB Output is correct
16 Correct 64 ms 528 KB Output is correct
17 Correct 106 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1093 ms 400 KB Output is correct
2 Correct 917 ms 496 KB Output is correct
3 Correct 792 ms 528 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 5 ms 476 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 693 ms 492 KB Output is correct
8 Correct 1099 ms 588 KB Output is correct
9 Correct 829 ms 528 KB Output is correct
10 Correct 783 ms 512 KB Output is correct
11 Correct 8 ms 596 KB Output is correct
12 Correct 4 ms 596 KB Output is correct
13 Correct 6 ms 596 KB Output is correct
14 Correct 5 ms 596 KB Output is correct
15 Correct 3 ms 464 KB Output is correct
16 Correct 704 ms 528 KB Output is correct
17 Correct 565 ms 508 KB Output is correct
18 Correct 638 ms 528 KB Output is correct
19 Correct 515 ms 528 KB Output is correct
20 Correct 625 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 602 ms 620 KB Partially correct
2 Partially correct 600 ms 640 KB Partially correct
3 Correct 962 ms 528 KB Output is correct
4 Correct 813 ms 656 KB Output is correct
5 Correct 798 ms 508 KB Output is correct
6 Partially correct 615 ms 644 KB Partially correct
7 Partially correct 628 ms 524 KB Partially correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 6 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Partially correct 518 ms 492 KB Partially correct
12 Partially correct 635 ms 544 KB Partially correct
13 Correct 1049 ms 488 KB Output is correct
14 Correct 1087 ms 488 KB Output is correct
15 Correct 640 ms 516 KB Output is correct
16 Partially correct 616 ms 512 KB Partially correct
17 Correct 649 ms 512 KB Output is correct
18 Partially correct 590 ms 712 KB Partially correct
19 Partially correct 555 ms 632 KB Partially correct
20 Partially correct 538 ms 504 KB Partially correct
21 Correct 71 ms 580 KB Output is correct
22 Partially correct 96 ms 528 KB Partially correct
23 Partially correct 124 ms 528 KB Partially correct
24 Correct 5 ms 596 KB Output is correct
25 Correct 5 ms 596 KB Output is correct
26 Correct 6 ms 596 KB Output is correct
27 Correct 5 ms 420 KB Output is correct
28 Correct 2 ms 476 KB Output is correct
29 Correct 521 ms 400 KB Output is correct
30 Correct 591 ms 504 KB Output is correct
31 Correct 614 ms 512 KB Output is correct
32 Correct 639 ms 508 KB Output is correct
33 Correct 537 ms 500 KB Output is correct
34 Partially correct 368 ms 528 KB Partially correct
35 Partially correct 494 ms 764 KB Partially correct
36 Partially correct 467 ms 640 KB Partially correct
37 Partially correct 541 ms 636 KB Partially correct
38 Partially correct 606 ms 624 KB Partially correct
39 Partially correct 515 ms 796 KB Partially correct
40 Partially correct 556 ms 628 KB Partially correct
41 Partially correct 680 ms 712 KB Partially correct
42 Partially correct 83 ms 528 KB Partially correct
43 Partially correct 160 ms 728 KB Partially correct
44 Partially correct 154 ms 528 KB Partially correct
45 Partially correct 167 ms 604 KB Partially correct
46 Partially correct 464 ms 656 KB Partially correct
47 Partially correct 366 ms 512 KB Partially correct
48 Partially correct 54 ms 752 KB Partially correct
49 Partially correct 68 ms 660 KB Partially correct