Submission #430493

# Submission time Handle Problem Language Result Execution time Memory
430493 2021-06-16T14:39:39 Z alishahali1382 Stations (IOI20_stations) C++14
76 / 100
1295 ms 828 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()+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(), 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 500 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 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 637 ms 628 KB Output is correct
2 Correct 648 ms 824 KB Output is correct
3 Correct 1041 ms 508 KB Output is correct
4 Correct 903 ms 500 KB Output is correct
5 Correct 618 ms 512 KB Output is correct
6 Correct 568 ms 528 KB Output is correct
7 Correct 583 ms 652 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 4 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 746 ms 572 KB Output is correct
12 Correct 669 ms 732 KB Output is correct
13 Correct 533 ms 728 KB Output is correct
14 Correct 612 ms 656 KB Output is correct
15 Correct 100 ms 528 KB Output is correct
16 Correct 72 ms 656 KB Output is correct
17 Correct 174 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 988 ms 508 KB Output is correct
2 Correct 653 ms 512 KB Output is correct
3 Correct 857 ms 504 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 820 ms 604 KB Output is correct
8 Correct 1115 ms 504 KB Output is correct
9 Correct 905 ms 508 KB Output is correct
10 Correct 651 ms 596 KB Output is correct
11 Correct 8 ms 468 KB Output is correct
12 Correct 4 ms 464 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Correct 6 ms 596 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 727 ms 508 KB Output is correct
17 Correct 563 ms 588 KB Output is correct
18 Correct 796 ms 584 KB Output is correct
19 Correct 872 ms 528 KB Output is correct
20 Correct 593 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 656 ms 640 KB Partially correct
2 Partially correct 521 ms 632 KB Partially correct
3 Correct 1192 ms 528 KB Output is correct
4 Correct 883 ms 400 KB Output is correct
5 Correct 709 ms 512 KB Output is correct
6 Partially correct 673 ms 652 KB Partially correct
7 Partially correct 568 ms 528 KB Partially correct
8 Correct 3 ms 652 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 517 ms 488 KB Partially correct
12 Partially correct 746 ms 500 KB Partially correct
13 Correct 1295 ms 508 KB Output is correct
14 Correct 648 ms 528 KB Output is correct
15 Correct 730 ms 500 KB Output is correct
16 Partially correct 611 ms 500 KB Partially correct
17 Correct 754 ms 400 KB Output is correct
18 Partially correct 574 ms 732 KB Partially correct
19 Partially correct 560 ms 732 KB Partially correct
20 Partially correct 531 ms 512 KB Partially correct
21 Correct 78 ms 528 KB Output is correct
22 Partially correct 80 ms 528 KB Partially correct
23 Partially correct 177 ms 656 KB Partially correct
24 Correct 7 ms 596 KB Output is correct
25 Correct 8 ms 592 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 588 ms 400 KB Output is correct
30 Correct 734 ms 512 KB Output is correct
31 Correct 645 ms 532 KB Output is correct
32 Correct 601 ms 528 KB Output is correct
33 Correct 762 ms 512 KB Output is correct
34 Partially correct 329 ms 616 KB Partially correct
35 Partially correct 533 ms 732 KB Partially correct
36 Partially correct 489 ms 728 KB Partially correct
37 Partially correct 705 ms 612 KB Partially correct
38 Partially correct 672 ms 704 KB Partially correct
39 Partially correct 675 ms 732 KB Partially correct
40 Partially correct 626 ms 712 KB Partially correct
41 Partially correct 776 ms 716 KB Partially correct
42 Partially correct 75 ms 660 KB Partially correct
43 Partially correct 176 ms 728 KB Partially correct
44 Partially correct 193 ms 828 KB Partially correct
45 Partially correct 235 ms 596 KB Partially correct
46 Partially correct 568 ms 500 KB Partially correct
47 Partially correct 385 ms 576 KB Partially correct
48 Partially correct 84 ms 656 KB Partially correct
49 Partially correct 86 ms 752 KB Partially correct