Submission #306430

# Submission time Handle Problem Language Result Execution time Memory
306430 2020-09-25T14:47:54 Z CaroLinda Stations (IOI20_stations) C++14
76 / 100
890 ms 1184 KB
#include "stations.h"
#include <bits/stdc++.h>

#define lp(i,a,b) for(int i = a; i < b;  i++)
#define debug //printf
#define ff first
#define ss second
#define mk make_pair
#define ll long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x.size())

const int MAXN = 1010 ;

using namespace std ;

int tin[MAXN] , tout[MAXN] ;
vector<int> adj[MAXN] ;

int currTime = -1 ;
void dfs(int x, int father)
{
	tin[x] = tout[x] = ++currTime ;
	for(auto e :adj[x])
	{
		if(e == father) continue ;

		dfs(e,x) ;

		tout[x] = ++currTime ;

	}

	if( (tin[x]&1) != (tout[x]&1) ) tout[x] = ++currTime ;

}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	
	for(int i = 0 ; i < n ; i++ ) adj[i].clear() ;
	currTime = -1 ;

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

	dfs(0,-1) ;


	vector<int> labels(n) ;

	for(int i = 0 ; i < n ; i++ )
	{
		if(tin[i]&1) labels[i] = tin[i] ;
		else labels[i] = tout[i] ;
	}

	lp(i,0,n) debug("%d %d\n" , i , labels[i]) ;

	return labels ;

}

int find_next_station(int s, int t, std::vector<int> c) {
	
	for(auto e: c ) 
		if(e == t) return t ;

	if( c[0]&1 )
	{
		//ou seja, tenho os tin's

		if(t > s ) return c[0] ;

		for(int  i = sz(c) - 1 ; i>= 0 ; i-- )
			if( c[i] < t ) return c[i] ;

		return c[0] ;

	}
	else 
	{
		//tenho os tout's

		if( t < s ) return c[ sz(c)-1 ] ;

		for(int i = 0 ; i < sz(c) ; i++ )
			if( c[i] > t ) return c[i] ;

		return c[ sz(c)-1 ] ;

	}

}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:61:18: warning: left operand of comma operator has no effect [-Wunused-value]
   61 |  lp(i,0,n) debug("%d %d\n" , i , labels[i]) ;
      |                  ^~~~~~~~~
stations.cpp:61:42: warning: right operand of comma operator has no effect [-Wunused-value]
   61 |  lp(i,0,n) debug("%d %d\n" , i , labels[i]) ;
      |                                          ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 496 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=0, label=1994
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1990
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 536 ms 1008 KB Output is correct
2 Correct 472 ms 1008 KB Output is correct
3 Correct 882 ms 868 KB Output is correct
4 Correct 688 ms 1040 KB Output is correct
5 Correct 591 ms 868 KB Output is correct
6 Correct 458 ms 776 KB Output is correct
7 Correct 480 ms 792 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 585 ms 1132 KB Output is correct
12 Correct 504 ms 888 KB Output is correct
13 Correct 485 ms 1132 KB Output is correct
14 Correct 473 ms 820 KB Output is correct
15 Correct 61 ms 768 KB Output is correct
16 Correct 74 ms 828 KB Output is correct
17 Correct 126 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 887 ms 896 KB Output is correct
2 Correct 717 ms 1024 KB Output is correct
3 Correct 625 ms 768 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 2 ms 1036 KB Output is correct
7 Correct 607 ms 768 KB Output is correct
8 Correct 880 ms 768 KB Output is correct
9 Correct 666 ms 768 KB Output is correct
10 Correct 577 ms 1024 KB Output is correct
11 Correct 6 ms 768 KB Output is correct
12 Correct 6 ms 872 KB Output is correct
13 Correct 4 ms 876 KB Output is correct
14 Correct 4 ms 872 KB Output is correct
15 Correct 1 ms 876 KB Output is correct
16 Correct 503 ms 1024 KB Output is correct
17 Correct 548 ms 768 KB Output is correct
18 Correct 504 ms 864 KB Output is correct
19 Correct 499 ms 872 KB Output is correct
20 Correct 512 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 546 ms 1004 KB Partially correct
2 Partially correct 465 ms 1000 KB Partially correct
3 Correct 890 ms 768 KB Output is correct
4 Correct 691 ms 1184 KB Output is correct
5 Correct 614 ms 1024 KB Output is correct
6 Partially correct 450 ms 1024 KB Partially correct
7 Partially correct 462 ms 796 KB Partially correct
8 Correct 3 ms 876 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Partially correct 492 ms 768 KB Partially correct
12 Partially correct 536 ms 816 KB Partially correct
13 Correct 882 ms 768 KB Output is correct
14 Correct 690 ms 872 KB Output is correct
15 Correct 604 ms 768 KB Output is correct
16 Partially correct 467 ms 816 KB Partially correct
17 Correct 586 ms 1024 KB Output is correct
18 Partially correct 482 ms 1000 KB Partially correct
19 Partially correct 485 ms 1008 KB Partially correct
20 Partially correct 467 ms 820 KB Partially correct
21 Correct 61 ms 860 KB Output is correct
22 Partially correct 79 ms 836 KB Partially correct
23 Partially correct 119 ms 796 KB Partially correct
24 Correct 5 ms 872 KB Output is correct
25 Correct 5 ms 768 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 4 ms 868 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 520 ms 1040 KB Output is correct
30 Correct 513 ms 1168 KB Output is correct
31 Correct 485 ms 1024 KB Output is correct
32 Correct 487 ms 868 KB Output is correct
33 Correct 510 ms 768 KB Output is correct
34 Partially correct 323 ms 964 KB Partially correct
35 Partially correct 440 ms 1132 KB Partially correct
36 Partially correct 473 ms 1124 KB Partially correct
37 Partially correct 463 ms 896 KB Partially correct
38 Partially correct 472 ms 884 KB Partially correct
39 Partially correct 453 ms 772 KB Partially correct
40 Partially correct 462 ms 1000 KB Partially correct
41 Partially correct 480 ms 908 KB Partially correct
42 Partially correct 66 ms 768 KB Partially correct
43 Partially correct 114 ms 784 KB Partially correct
44 Partially correct 132 ms 792 KB Partially correct
45 Partially correct 159 ms 780 KB Partially correct
46 Partially correct 341 ms 820 KB Partially correct
47 Partially correct 310 ms 792 KB Partially correct
48 Partially correct 67 ms 1028 KB Partially correct
49 Partially correct 63 ms 1024 KB Partially correct