Submission #310318

# Submission time Handle Problem Language Result Execution time Memory
310318 2020-10-06T16:20:50 Z Peacher29 Stations (IOI20_stations) C++14
100 / 100
1025 ms 1024 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

class pont{
public:
	vector<int> v;
	int id=-1;
	void dfs(bool mi);
};

int dd;
vector<pont> p;

void pont::dfs(bool mi){
	if(id==-1){
		if(mi){
			id=-2;
		} else {
			id=++dd;
		}
		for(int i : v){
			p[i].dfs(!mi);
		}
		if(mi){
			id=++dd;
		}
	}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	p.clear();
	p.resize(n);
	dd=-1;
	for(int i=0;i<n-1;i++){
		p[u[i]].v.push_back(v[i]);
		p[v[i]].v.push_back(u[i]);
	}
	p[0].dfs(0);
	vector<int> er(n);
	for(int i=0;i<n;i++){
		er[i] = p[i].id;
		//cout << er[i] << ' ';
	}
	return er;
}
int find_next_station(int s, int t, vector<int> c) {
	if(s==t){
		exit(255);
	}
	if(c.size()==1){
		return c[0];
	}
	sort(c.begin(), c.end());
	/*cout << s << "->" << t << '\n';
	for(int i : c){
		cout << i << ' ';
	}
	cout << '\n';*/
	if(s<c[0]){
		if(t<s || c[c.size()-2]<t){
			return c[c.size()-1];
		} else {
			for(int i=0;i<=c.size()-2;i++){
				if(t<=c[i]){
					return c[i];
				}
			}
		}
	} else {
		if(t>s || c[1]>t){
			return c[0];
		} else {
			for(int i=c.size()-1;i>=(s!=0);i--){
				if(c[i]<=t){
					return c[i];
				}
			}
		}
	}
	exit(255);
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:65:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    for(int i=0;i<=c.size()-2;i++){
      |                ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 514 ms 1024 KB Output is correct
2 Correct 461 ms 1024 KB Output is correct
3 Correct 880 ms 644 KB Output is correct
4 Correct 747 ms 644 KB Output is correct
5 Correct 730 ms 640 KB Output is correct
6 Correct 592 ms 768 KB Output is correct
7 Correct 461 ms 788 KB Output is correct
8 Correct 3 ms 644 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 457 ms 1024 KB Output is correct
2 Correct 535 ms 816 KB Output is correct
3 Correct 982 ms 644 KB Output is correct
4 Correct 734 ms 640 KB Output is correct
5 Correct 631 ms 656 KB Output is correct
6 Correct 467 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 547 ms 1024 KB Output is correct
2 Correct 486 ms 1008 KB Output is correct
3 Correct 1023 ms 640 KB Output is correct
4 Correct 744 ms 748 KB Output is correct
5 Correct 580 ms 784 KB Output is correct
6 Correct 487 ms 780 KB Output is correct
7 Correct 435 ms 796 KB Output is correct
8 Correct 3 ms 644 KB Output is correct
9 Correct 4 ms 656 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
11 Correct 686 ms 644 KB Output is correct
12 Correct 468 ms 768 KB Output is correct
13 Correct 536 ms 780 KB Output is correct
14 Correct 582 ms 804 KB Output is correct
15 Correct 54 ms 892 KB Output is correct
16 Correct 69 ms 856 KB Output is correct
17 Correct 117 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1025 ms 644 KB Output is correct
2 Correct 792 ms 640 KB Output is correct
3 Correct 641 ms 644 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Correct 4 ms 652 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 681 ms 640 KB Output is correct
8 Correct 928 ms 760 KB Output is correct
9 Correct 789 ms 640 KB Output is correct
10 Correct 622 ms 644 KB Output is correct
11 Correct 6 ms 644 KB Output is correct
12 Correct 7 ms 640 KB Output is correct
13 Correct 6 ms 644 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 2 ms 640 KB Output is correct
16 Correct 607 ms 784 KB Output is correct
17 Correct 615 ms 648 KB Output is correct
18 Correct 505 ms 648 KB Output is correct
19 Correct 609 ms 644 KB Output is correct
20 Correct 489 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 622 ms 768 KB Output is correct
2 Correct 577 ms 1008 KB Output is correct
3 Correct 889 ms 648 KB Output is correct
4 Correct 643 ms 648 KB Output is correct
5 Correct 593 ms 648 KB Output is correct
6 Correct 461 ms 764 KB Output is correct
7 Correct 490 ms 804 KB Output is correct
8 Correct 3 ms 644 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 1 ms 648 KB Output is correct
11 Correct 459 ms 1024 KB Output is correct
12 Correct 522 ms 760 KB Output is correct
13 Correct 950 ms 644 KB Output is correct
14 Correct 851 ms 648 KB Output is correct
15 Correct 690 ms 652 KB Output is correct
16 Correct 486 ms 824 KB Output is correct
17 Correct 585 ms 784 KB Output is correct
18 Correct 549 ms 888 KB Output is correct
19 Correct 552 ms 768 KB Output is correct
20 Correct 455 ms 832 KB Output is correct
21 Correct 71 ms 896 KB Output is correct
22 Correct 79 ms 768 KB Output is correct
23 Correct 144 ms 768 KB Output is correct
24 Correct 8 ms 652 KB Output is correct
25 Correct 7 ms 640 KB Output is correct
26 Correct 4 ms 648 KB Output is correct
27 Correct 4 ms 652 KB Output is correct
28 Correct 2 ms 640 KB Output is correct
29 Correct 540 ms 648 KB Output is correct
30 Correct 590 ms 640 KB Output is correct
31 Correct 558 ms 784 KB Output is correct
32 Correct 571 ms 652 KB Output is correct
33 Correct 498 ms 640 KB Output is correct
34 Correct 332 ms 1024 KB Output is correct
35 Correct 425 ms 1024 KB Output is correct
36 Correct 521 ms 1024 KB Output is correct
37 Correct 532 ms 1004 KB Output is correct
38 Correct 485 ms 784 KB Output is correct
39 Correct 531 ms 888 KB Output is correct
40 Correct 477 ms 892 KB Output is correct
41 Correct 550 ms 888 KB Output is correct
42 Correct 78 ms 828 KB Output is correct
43 Correct 109 ms 768 KB Output is correct
44 Correct 140 ms 824 KB Output is correct
45 Correct 177 ms 808 KB Output is correct
46 Correct 304 ms 956 KB Output is correct
47 Correct 319 ms 804 KB Output is correct
48 Correct 67 ms 948 KB Output is correct
49 Correct 66 ms 804 KB Output is correct