Submission #393351

# Submission time Handle Problem Language Result Execution time Memory
393351 2021-04-23T09:35:35 Z lighton Stations (IOI20_stations) C++17
100 / 100
1059 ms 784 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
int p = 1;
int chk[1001];
vector<int> vec[1001];
void dfs(int now , int d){
    if((d%2) == 0) chk[now] = p++;
    else chk[now] = 1;
    for(int i : vec[now]){
        if(!chk[i]) dfs(i,d+1);
    }
    if((d%2) == 1) chk[now] = p++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels(n);
    p = 1;
    for(int i = 0; i<n; i++){
        chk[i] = 0;
        vec[i].clear();
    }
    for(int i = 0; i < u.size(); i++){
        vec[v[i]].push_back(u[i]);
        vec[u[i]].push_back(v[i]);
    }
	dfs(0,0);
	for (int i = 0; i < n; i++) {
		labels[i] = chk[i];
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	if(c[c.size()-1] < s){
        if(t > s) return c[0];
        if(t < c[0]) return c[0];
        return c[upper_bound(c.begin() , c.end() , t)-c.begin()-1];
	}
    else{
        if(t < s) return c[c.size()-1];
        if(t > c[c.size()-1]) return c[c.size()-1];
        return c[lower_bound(c.begin() , c.end() , t)-c.begin()];
    }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < u.size(); i++){
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 674 ms 588 KB Output is correct
2 Correct 464 ms 528 KB Output is correct
3 Correct 1049 ms 400 KB Output is correct
4 Correct 714 ms 400 KB Output is correct
5 Correct 614 ms 504 KB Output is correct
6 Correct 489 ms 516 KB Output is correct
7 Correct 561 ms 528 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 4 ms 488 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 558 ms 784 KB Output is correct
2 Correct 595 ms 516 KB Output is correct
3 Correct 1047 ms 400 KB Output is correct
4 Correct 639 ms 516 KB Output is correct
5 Correct 719 ms 400 KB Output is correct
6 Correct 537 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 628 ms 652 KB Output is correct
2 Correct 531 ms 520 KB Output is correct
3 Correct 1017 ms 508 KB Output is correct
4 Correct 756 ms 400 KB Output is correct
5 Correct 701 ms 520 KB Output is correct
6 Correct 559 ms 632 KB Output is correct
7 Correct 486 ms 660 KB Output is correct
8 Correct 3 ms 480 KB Output is correct
9 Correct 6 ms 472 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
11 Correct 637 ms 400 KB Output is correct
12 Correct 464 ms 656 KB Output is correct
13 Correct 564 ms 636 KB Output is correct
14 Correct 482 ms 532 KB Output is correct
15 Correct 68 ms 528 KB Output is correct
16 Correct 72 ms 532 KB Output is correct
17 Correct 103 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 984 ms 520 KB Output is correct
2 Correct 819 ms 524 KB Output is correct
3 Correct 717 ms 404 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 4 ms 736 KB Output is correct
6 Correct 2 ms 472 KB Output is correct
7 Correct 623 ms 516 KB Output is correct
8 Correct 968 ms 512 KB Output is correct
9 Correct 654 ms 400 KB Output is correct
10 Correct 646 ms 404 KB Output is correct
11 Correct 6 ms 596 KB Output is correct
12 Correct 7 ms 480 KB Output is correct
13 Correct 6 ms 600 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 630 ms 528 KB Output is correct
17 Correct 638 ms 528 KB Output is correct
18 Correct 552 ms 528 KB Output is correct
19 Correct 613 ms 528 KB Output is correct
20 Correct 609 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 560 ms 532 KB Output is correct
2 Correct 461 ms 516 KB Output is correct
3 Correct 1059 ms 516 KB Output is correct
4 Correct 705 ms 404 KB Output is correct
5 Correct 664 ms 528 KB Output is correct
6 Correct 435 ms 640 KB Output is correct
7 Correct 483 ms 528 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 4 ms 472 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
11 Correct 511 ms 660 KB Output is correct
12 Correct 586 ms 528 KB Output is correct
13 Correct 946 ms 476 KB Output is correct
14 Correct 859 ms 676 KB Output is correct
15 Correct 638 ms 400 KB Output is correct
16 Correct 486 ms 532 KB Output is correct
17 Correct 611 ms 400 KB Output is correct
18 Correct 417 ms 636 KB Output is correct
19 Correct 492 ms 656 KB Output is correct
20 Correct 448 ms 524 KB Output is correct
21 Correct 69 ms 608 KB Output is correct
22 Correct 92 ms 580 KB Output is correct
23 Correct 147 ms 680 KB Output is correct
24 Correct 7 ms 480 KB Output is correct
25 Correct 7 ms 600 KB Output is correct
26 Correct 5 ms 604 KB Output is correct
27 Correct 5 ms 472 KB Output is correct
28 Correct 2 ms 472 KB Output is correct
29 Correct 597 ms 524 KB Output is correct
30 Correct 585 ms 528 KB Output is correct
31 Correct 511 ms 400 KB Output is correct
32 Correct 619 ms 400 KB Output is correct
33 Correct 543 ms 512 KB Output is correct
34 Correct 404 ms 528 KB Output is correct
35 Correct 592 ms 656 KB Output is correct
36 Correct 581 ms 640 KB Output is correct
37 Correct 435 ms 528 KB Output is correct
38 Correct 580 ms 656 KB Output is correct
39 Correct 496 ms 628 KB Output is correct
40 Correct 511 ms 628 KB Output is correct
41 Correct 578 ms 640 KB Output is correct
42 Correct 80 ms 580 KB Output is correct
43 Correct 136 ms 656 KB Output is correct
44 Correct 173 ms 592 KB Output is correct
45 Correct 190 ms 528 KB Output is correct
46 Correct 328 ms 520 KB Output is correct
47 Correct 386 ms 656 KB Output is correct
48 Correct 79 ms 656 KB Output is correct
49 Correct 72 ms 676 KB Output is correct