Submission #683006

# Submission time Handle Problem Language Result Execution time Memory
683006 2023-01-17T13:40:39 Z Eddard Stations (IOI20_stations) C++17
100 / 100
964 ms 872 KB
#include "stations.h"
#include <bits/stdc++.h>


using namespace std;


void setLabel(int u, int par, int f, vector<int> &labels, vector<vector<int>> &adj, int &c) {
    
    if (f) labels[u] = c++;
    
    for (auto v: adj[u]) if (v != par) setLabel(v, u, !f, labels, adj, c);
    
    if (!f) labels[u] = c++;
    
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    
    
    vector<int> labels(n, -1);
    vector<vector<int>> adj(n);
    int c = 0;
    
    for (int i = 0; i < n - 1; ++i) {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    
    setLabel(0, -1, 0, labels, adj, c);
    
    return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    
    if (s < c[0]) {
        
        if (t < s || t >= c.back()) return c.back();
        
        auto it = lower_bound(c.begin(), c.end(), t) - c.begin();
        return c[it];
        
    } else {
        
        if (t > s || t <= c[0]) return c[0];
        
        auto it = upper_bound(c.begin(), c.end(), t) - c.begin() - 1;
        return c[it];
        
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 570 ms 628 KB Output is correct
2 Correct 467 ms 672 KB Output is correct
3 Correct 807 ms 416 KB Output is correct
4 Correct 588 ms 416 KB Output is correct
5 Correct 606 ms 508 KB Output is correct
6 Correct 439 ms 544 KB Output is correct
7 Correct 445 ms 628 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 470 ms 548 KB Output is correct
2 Correct 512 ms 548 KB Output is correct
3 Correct 811 ms 420 KB Output is correct
4 Correct 644 ms 508 KB Output is correct
5 Correct 572 ms 428 KB Output is correct
6 Correct 465 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 503 ms 676 KB Output is correct
2 Correct 328 ms 628 KB Output is correct
3 Correct 892 ms 512 KB Output is correct
4 Correct 685 ms 504 KB Output is correct
5 Correct 550 ms 416 KB Output is correct
6 Correct 462 ms 636 KB Output is correct
7 Correct 427 ms 624 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 5 ms 492 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 595 ms 508 KB Output is correct
12 Correct 402 ms 708 KB Output is correct
13 Correct 417 ms 632 KB Output is correct
14 Correct 358 ms 548 KB Output is correct
15 Correct 49 ms 484 KB Output is correct
16 Correct 54 ms 512 KB Output is correct
17 Correct 110 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 902 ms 480 KB Output is correct
2 Correct 625 ms 504 KB Output is correct
3 Correct 578 ms 416 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 5 ms 492 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 537 ms 416 KB Output is correct
8 Correct 964 ms 420 KB Output is correct
9 Correct 700 ms 508 KB Output is correct
10 Correct 624 ms 416 KB Output is correct
11 Correct 5 ms 492 KB Output is correct
12 Correct 5 ms 492 KB Output is correct
13 Correct 5 ms 492 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 1 ms 500 KB Output is correct
16 Correct 477 ms 420 KB Output is correct
17 Correct 426 ms 416 KB Output is correct
18 Correct 525 ms 416 KB Output is correct
19 Correct 519 ms 444 KB Output is correct
20 Correct 501 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 529 ms 544 KB Output is correct
2 Correct 367 ms 544 KB Output is correct
3 Correct 794 ms 420 KB Output is correct
4 Correct 639 ms 420 KB Output is correct
5 Correct 572 ms 448 KB Output is correct
6 Correct 385 ms 676 KB Output is correct
7 Correct 339 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 5 ms 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 416 ms 492 KB Output is correct
12 Correct 475 ms 504 KB Output is correct
13 Correct 773 ms 420 KB Output is correct
14 Correct 579 ms 416 KB Output is correct
15 Correct 597 ms 416 KB Output is correct
16 Correct 378 ms 508 KB Output is correct
17 Correct 500 ms 508 KB Output is correct
18 Correct 487 ms 628 KB Output is correct
19 Correct 441 ms 712 KB Output is correct
20 Correct 427 ms 544 KB Output is correct
21 Correct 53 ms 472 KB Output is correct
22 Correct 73 ms 576 KB Output is correct
23 Correct 92 ms 544 KB Output is correct
24 Correct 3 ms 492 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 5 ms 492 KB Output is correct
27 Correct 3 ms 500 KB Output is correct
28 Correct 1 ms 500 KB Output is correct
29 Correct 495 ms 504 KB Output is correct
30 Correct 458 ms 416 KB Output is correct
31 Correct 488 ms 420 KB Output is correct
32 Correct 469 ms 504 KB Output is correct
33 Correct 529 ms 420 KB Output is correct
34 Correct 315 ms 756 KB Output is correct
35 Correct 404 ms 748 KB Output is correct
36 Correct 437 ms 548 KB Output is correct
37 Correct 468 ms 872 KB Output is correct
38 Correct 405 ms 628 KB Output is correct
39 Correct 481 ms 592 KB Output is correct
40 Correct 459 ms 716 KB Output is correct
41 Correct 442 ms 632 KB Output is correct
42 Correct 55 ms 548 KB Output is correct
43 Correct 112 ms 592 KB Output is correct
44 Correct 120 ms 548 KB Output is correct
45 Correct 158 ms 548 KB Output is correct
46 Correct 265 ms 548 KB Output is correct
47 Correct 293 ms 548 KB Output is correct
48 Correct 54 ms 568 KB Output is correct
49 Correct 59 ms 784 KB Output is correct