답안 #305252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305252 2020-09-22T19:28:52 Z oscarsierra12 기지국 (IOI20_stations) C++14
100 / 100
1095 ms 1240 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>

using namespace std ;

const int N = 1010 ;

int dfsNum[N];
int cnt = 0 ;
vector <int> G[N] ;

void dfs ( int u, int p, int f ) {
    if ( f ) dfsNum[u] = cnt++ ;
    for ( auto v:G[u] ) if ( v!=p ) dfs (v, u, 1-f) ;
    if ( !f ) dfsNum[u] = cnt++ ;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	for ( int i = 0 ; i < n ; ++i ) G[i].clear() ;
	cnt = 0 ;
	for ( int i = 0 ; i + 1 < n ; ++i ) {
        G[u[i]].push_back ( v[i] ) ;
        G[v[i]].push_back ( u[i] ) ;
	}
    dfs ( 0, -1, 0 ) ;
	for (int i = 0; i < n; i++) {
		labels[i] = dfsNum[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    sort ( c.begin(), c.end() ) ;
    if ( c[0] > s ) {
        ///s is timein
        if ( t < s ) return c.back() ;
        for ( auto i:c )
            if ( i >= t ) return i ;
        return c.back() ;
    }
    ///s is timeout
    if ( s < t ) return c[0] ;
    for ( int i = 1 ; i < c.size() ; ++i )
        if ( c[i] > t ) return c[i-1] ;
	return c.back();
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:25: 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() ; ++i )
      |                       ~~^~~~~~~~~~
stations.cpp:45:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   45 |     for ( int i = 1 ; i < c.size() ; ++i )
      |     ^~~
stations.cpp:47:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |  return c.back();
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 684 ms 1024 KB Output is correct
2 Correct 689 ms 1024 KB Output is correct
3 Correct 1057 ms 768 KB Output is correct
4 Correct 858 ms 896 KB Output is correct
5 Correct 629 ms 768 KB Output is correct
6 Correct 510 ms 992 KB Output is correct
7 Correct 668 ms 896 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 550 ms 768 KB Output is correct
2 Correct 735 ms 768 KB Output is correct
3 Correct 1047 ms 904 KB Output is correct
4 Correct 828 ms 896 KB Output is correct
5 Correct 701 ms 800 KB Output is correct
6 Correct 505 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 706 ms 1056 KB Output is correct
2 Correct 575 ms 1032 KB Output is correct
3 Correct 991 ms 780 KB Output is correct
4 Correct 806 ms 768 KB Output is correct
5 Correct 836 ms 792 KB Output is correct
6 Correct 559 ms 1008 KB Output is correct
7 Correct 603 ms 768 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 5 ms 776 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 753 ms 768 KB Output is correct
12 Correct 577 ms 1024 KB Output is correct
13 Correct 600 ms 1016 KB Output is correct
14 Correct 560 ms 800 KB Output is correct
15 Correct 51 ms 900 KB Output is correct
16 Correct 81 ms 768 KB Output is correct
17 Correct 162 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1095 ms 768 KB Output is correct
2 Correct 743 ms 800 KB Output is correct
3 Correct 743 ms 768 KB Output is correct
4 Correct 4 ms 800 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 679 ms 800 KB Output is correct
8 Correct 1083 ms 768 KB Output is correct
9 Correct 804 ms 784 KB Output is correct
10 Correct 795 ms 916 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 6 ms 768 KB Output is correct
13 Correct 7 ms 816 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 2 ms 768 KB Output is correct
16 Correct 764 ms 768 KB Output is correct
17 Correct 669 ms 896 KB Output is correct
18 Correct 680 ms 788 KB Output is correct
19 Correct 656 ms 896 KB Output is correct
20 Correct 680 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 610 ms 1016 KB Output is correct
2 Correct 593 ms 1024 KB Output is correct
3 Correct 924 ms 768 KB Output is correct
4 Correct 740 ms 768 KB Output is correct
5 Correct 709 ms 768 KB Output is correct
6 Correct 674 ms 1024 KB Output is correct
7 Correct 612 ms 780 KB Output is correct
8 Correct 4 ms 800 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 539 ms 896 KB Output is correct
12 Correct 605 ms 896 KB Output is correct
13 Correct 1075 ms 768 KB Output is correct
14 Correct 906 ms 768 KB Output is correct
15 Correct 580 ms 768 KB Output is correct
16 Correct 480 ms 824 KB Output is correct
17 Correct 664 ms 896 KB Output is correct
18 Correct 615 ms 1024 KB Output is correct
19 Correct 500 ms 1008 KB Output is correct
20 Correct 483 ms 832 KB Output is correct
21 Correct 64 ms 768 KB Output is correct
22 Correct 78 ms 832 KB Output is correct
23 Correct 118 ms 812 KB Output is correct
24 Correct 5 ms 768 KB Output is correct
25 Correct 6 ms 768 KB Output is correct
26 Correct 6 ms 768 KB Output is correct
27 Correct 4 ms 768 KB Output is correct
28 Correct 2 ms 768 KB Output is correct
29 Correct 734 ms 768 KB Output is correct
30 Correct 651 ms 768 KB Output is correct
31 Correct 602 ms 1000 KB Output is correct
32 Correct 524 ms 768 KB Output is correct
33 Correct 603 ms 768 KB Output is correct
34 Correct 447 ms 768 KB Output is correct
35 Correct 496 ms 1240 KB Output is correct
36 Correct 571 ms 1024 KB Output is correct
37 Correct 551 ms 876 KB Output is correct
38 Correct 467 ms 888 KB Output is correct
39 Correct 632 ms 996 KB Output is correct
40 Correct 523 ms 888 KB Output is correct
41 Correct 481 ms 916 KB Output is correct
42 Correct 79 ms 952 KB Output is correct
43 Correct 137 ms 936 KB Output is correct
44 Correct 176 ms 792 KB Output is correct
45 Correct 235 ms 788 KB Output is correct
46 Correct 319 ms 768 KB Output is correct
47 Correct 324 ms 792 KB Output is correct
48 Correct 68 ms 768 KB Output is correct
49 Correct 88 ms 1024 KB Output is correct