Submission #474453

# Submission time Handle Problem Language Result Execution time Memory
474453 2021-09-18T09:27:38 Z cs71107 Stations (IOI20_stations) C++14
69.868 / 100
1190 ms 744 KB
#include "stations.h"

#include <bits/stdc++.h>

using namespace std;

const int MAXM = 1e3+10;

vector<vector<int> > graph;

int depth[MAXM];
int val[MAXM];

int seq = 0;

void dfs(int here,int p){

	int there;

	if(!(depth[here]&1)){
		val[here] = seq;
		seq++;
	}


	for(int i=0;i<(int)graph[here].size();i++){
		there = graph[here][i];
		if(there==p)continue;
		depth[there] = depth[here]^1;
		dfs(there,here);
	}

	if(depth[here]&1){
		val[here] = seq;
		seq++;
	}

	return;
}


std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {

	graph = vector<vector<int> > (n);

	for(int i=0;i<n-1;i++){
		graph[u[i]].push_back(v[i]);
		graph[v[i]].push_back(u[i]);
	}

	dfs(0,-1);

	vector<int> labels(n);

	for(int i=0;i<n;i++){
		labels[i] = val[i];
	}

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	
	int m = (int)c.size();

	if(m==1)return c[0];

	int idx = -1;
	int pre = 0;
	int nxt = 0;

	if(s<c[0]){
		
		pre = s;

		for(int i=0;i<m-1;i++){
			if(pre+1<=t&&t<=c[i]){
				idx = i;
				break;
			}
			pre = c[i];
		}

		if(idx==-1)idx = m-1;

	}
	else {

		for(int i=1;i<m;i++){
			if(i==m-1)nxt = s;
			else nxt = c[i+1];

			if(c[i]<=t&&t<=nxt-1){
				idx = i;
				break;
			}
		}

		if(idx==-1)idx = 0;
	}
	
	assert(idx!=-1);

	return c[idx];
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 412 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 412 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 720 ms 608 KB Output is correct
2 Correct 674 ms 656 KB Output is correct
3 Correct 972 ms 400 KB Output is correct
4 Correct 802 ms 468 KB Output is correct
5 Correct 822 ms 400 KB Output is correct
6 Correct 652 ms 616 KB Output is correct
7 Correct 597 ms 624 KB Output is correct
8 Correct 3 ms 464 KB Output is correct
9 Correct 4 ms 480 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 707 ms 400 KB Output is correct
12 Correct 546 ms 744 KB Output is correct
13 Correct 669 ms 696 KB Output is correct
14 Correct 522 ms 492 KB Output is correct
15 Correct 79 ms 404 KB Output is correct
16 Correct 60 ms 576 KB Output is correct
17 Correct 137 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1053 ms 400 KB Output is correct
2 Correct 641 ms 400 KB Output is correct
3 Correct 877 ms 400 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 4 ms 480 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 637 ms 492 KB Output is correct
8 Correct 1014 ms 400 KB Output is correct
9 Correct 732 ms 400 KB Output is correct
10 Correct 819 ms 492 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 3 ms 536 KB Output is correct
16 Correct 642 ms 496 KB Output is correct
17 Correct 654 ms 400 KB Output is correct
18 Correct 683 ms 400 KB Output is correct
19 Correct 693 ms 400 KB Output is correct
20 Correct 805 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 489 ms 620 KB Partially correct
2 Partially correct 662 ms 608 KB Partially correct
3 Correct 875 ms 400 KB Output is correct
4 Correct 918 ms 400 KB Output is correct
5 Correct 787 ms 400 KB Output is correct
6 Partially correct 634 ms 612 KB Partially correct
7 Correct 622 ms 528 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Partially correct 534 ms 600 KB Partially correct
12 Partially correct 786 ms 488 KB Partially correct
13 Correct 1190 ms 400 KB Output is correct
14 Correct 641 ms 492 KB Output is correct
15 Correct 833 ms 400 KB Output is correct
16 Correct 422 ms 488 KB Output is correct
17 Correct 606 ms 496 KB Output is correct
18 Partially correct 436 ms 700 KB Partially correct
19 Partially correct 670 ms 732 KB Partially correct
20 Correct 427 ms 492 KB Output is correct
21 Correct 69 ms 400 KB Output is correct
22 Partially correct 103 ms 564 KB Partially correct
23 Partially correct 99 ms 528 KB Partially correct
24 Correct 7 ms 468 KB Output is correct
25 Correct 7 ms 468 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 3 ms 464 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 544 ms 400 KB Output is correct
30 Correct 669 ms 492 KB Output is correct
31 Correct 448 ms 400 KB Output is correct
32 Correct 506 ms 400 KB Output is correct
33 Correct 509 ms 492 KB Output is correct
34 Partially correct 443 ms 620 KB Partially correct
35 Partially correct 538 ms 608 KB Partially correct
36 Partially correct 477 ms 624 KB Partially correct
37 Partially correct 591 ms 696 KB Partially correct
38 Partially correct 450 ms 544 KB Partially correct
39 Partially correct 625 ms 704 KB Partially correct
40 Partially correct 473 ms 656 KB Partially correct
41 Partially correct 623 ms 716 KB Partially correct
42 Partially correct 79 ms 596 KB Partially correct
43 Partially correct 147 ms 528 KB Partially correct
44 Partially correct 180 ms 548 KB Partially correct
45 Partially correct 145 ms 628 KB Partially correct
46 Partially correct 301 ms 528 KB Partially correct
47 Partially correct 422 ms 620 KB Partially correct
48 Partially correct 79 ms 528 KB Partially correct
49 Partially correct 61 ms 620 KB Partially correct