Submission #311960

# Submission time Handle Problem Language Result Execution time Memory
311960 2020-10-12T04:32:03 Z tzxydby Stations (IOI20_stations) C++14
100 / 100
991 ms 1328 KB
#include"stations.h"
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
vector<int>e[N],a;
int c;
void dfs(int u,int f,int d)
{
	if(d)
		a[u]=c++;
	for(auto v:e[u])
		if(v!=f)
			dfs(v,u,d^1);
	if(!d)
		a[u]=c++;
}
vector<int> label(int n,int k,vector<int>u,vector<int>v)
{
	a.assign(n,0);
	for(int i=0;i<n;i++)
		e[i].clear();
	c=0;
	for(int i=0;i<n-1;i++)
	{
		e[u[i]].push_back(v[i]);
		e[v[i]].push_back(u[i]);
	}
	dfs(0,0,0);
	a[0]=1000;
	return a;
}
int find_next_station(int s,int t,vector<int>c)
{
	if(c.size()==1)
		return c[0];
	if(s==1000)
	{
		for(int i=0;i<c.size()-1;i++)
			if(c[i]<=t&&t<c[i+1])
				return c[i];
		return c.back();
	}
	else if(s>c.back())
	{
		for(int i=1;i<c.size()-1;i++)
			if(c[i]<=t&&t<c[i+1])
				return c[i];
		if(c.back()<=t&&t<s)
			return c.back();
		return c[0];
	}
	else
	{
		if(s<t&&t<=c[0])
			return c[0];
		for(int i=1;i<c.size()-1;i++)
			if(c[i-1]<t&&t<=c[i])
				return c[i];
		return c.back();
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for(int i=0;i<c.size()-1;i++)
      |               ~^~~~~~~~~~~
stations.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i=1;i<c.size()-1;i++)
      |               ~^~~~~~~~~~~
stations.cpp:56:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   for(int i=1;i<c.size()-1;i++)
      |               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 551 ms 1024 KB Output is correct
2 Correct 503 ms 1024 KB Output is correct
3 Correct 937 ms 768 KB Output is correct
4 Correct 673 ms 768 KB Output is correct
5 Correct 608 ms 876 KB Output is correct
6 Correct 491 ms 1024 KB Output is correct
7 Correct 451 ms 780 KB Output is correct
8 Correct 3 ms 876 KB Output is correct
9 Correct 4 ms 880 KB Output is correct
10 Correct 2 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 550 ms 816 KB Output is correct
2 Correct 547 ms 768 KB Output is correct
3 Correct 923 ms 876 KB Output is correct
4 Correct 728 ms 880 KB Output is correct
5 Correct 686 ms 872 KB Output is correct
6 Correct 562 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 686 ms 1024 KB Output is correct
2 Correct 541 ms 1016 KB Output is correct
3 Correct 991 ms 768 KB Output is correct
4 Correct 667 ms 896 KB Output is correct
5 Correct 667 ms 876 KB Output is correct
6 Correct 518 ms 1280 KB Output is correct
7 Correct 463 ms 768 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 888 KB Output is correct
11 Correct 608 ms 768 KB Output is correct
12 Correct 565 ms 1024 KB Output is correct
13 Correct 566 ms 1124 KB Output is correct
14 Correct 510 ms 768 KB Output is correct
15 Correct 72 ms 876 KB Output is correct
16 Correct 83 ms 768 KB Output is correct
17 Correct 100 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 847 ms 768 KB Output is correct
2 Correct 698 ms 1024 KB Output is correct
3 Correct 643 ms 1032 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 2 ms 884 KB Output is correct
7 Correct 740 ms 792 KB Output is correct
8 Correct 986 ms 880 KB Output is correct
9 Correct 718 ms 880 KB Output is correct
10 Correct 672 ms 880 KB Output is correct
11 Correct 7 ms 768 KB Output is correct
12 Correct 7 ms 884 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 4 ms 872 KB Output is correct
15 Correct 2 ms 876 KB Output is correct
16 Correct 522 ms 1040 KB Output is correct
17 Correct 521 ms 880 KB Output is correct
18 Correct 534 ms 1040 KB Output is correct
19 Correct 549 ms 768 KB Output is correct
20 Correct 557 ms 872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 671 ms 1024 KB Output is correct
2 Correct 454 ms 1280 KB Output is correct
3 Correct 970 ms 1024 KB Output is correct
4 Correct 784 ms 768 KB Output is correct
5 Correct 714 ms 880 KB Output is correct
6 Correct 461 ms 1024 KB Output is correct
7 Correct 530 ms 788 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 888 KB Output is correct
11 Correct 577 ms 808 KB Output is correct
12 Correct 699 ms 768 KB Output is correct
13 Correct 933 ms 872 KB Output is correct
14 Correct 795 ms 880 KB Output is correct
15 Correct 679 ms 768 KB Output is correct
16 Correct 549 ms 832 KB Output is correct
17 Correct 709 ms 880 KB Output is correct
18 Correct 631 ms 772 KB Output is correct
19 Correct 602 ms 1024 KB Output is correct
20 Correct 571 ms 808 KB Output is correct
21 Correct 57 ms 1004 KB Output is correct
22 Correct 89 ms 848 KB Output is correct
23 Correct 145 ms 768 KB Output is correct
24 Correct 6 ms 1024 KB Output is correct
25 Correct 6 ms 888 KB Output is correct
26 Correct 6 ms 768 KB Output is correct
27 Correct 4 ms 880 KB Output is correct
28 Correct 2 ms 768 KB Output is correct
29 Correct 493 ms 872 KB Output is correct
30 Correct 528 ms 880 KB Output is correct
31 Correct 529 ms 876 KB Output is correct
32 Correct 561 ms 792 KB Output is correct
33 Correct 556 ms 876 KB Output is correct
34 Correct 446 ms 1024 KB Output is correct
35 Correct 461 ms 1328 KB Output is correct
36 Correct 467 ms 1024 KB Output is correct
37 Correct 482 ms 888 KB Output is correct
38 Correct 574 ms 780 KB Output is correct
39 Correct 513 ms 768 KB Output is correct
40 Correct 589 ms 772 KB Output is correct
41 Correct 527 ms 1156 KB Output is correct
42 Correct 83 ms 824 KB Output is correct
43 Correct 134 ms 768 KB Output is correct
44 Correct 129 ms 788 KB Output is correct
45 Correct 172 ms 768 KB Output is correct
46 Correct 386 ms 812 KB Output is correct
47 Correct 310 ms 1224 KB Output is correct
48 Correct 77 ms 768 KB Output is correct
49 Correct 77 ms 1024 KB Output is correct