Submission #806862

# Submission time Handle Problem Language Result Execution time Memory
806862 2023-08-04T10:36:20 Z borisAngelov Stations (IOI20_stations) C++17
52.3205 / 100
772 ms 764 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1005;

vector<int> g[maxn];

int tim = 0;

vector<int> hashed;

void dfs(int node, int par)
{
    hashed[node] = tim * 1000;
    ++tim;

    for (int i = 0; i < g[node].size(); ++i)
    {
        if (g[node][i] != par)
        {
            dfs(g[node][i], node);
        }
    }

    hashed[node] += (tim - 1);
}

vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
    for (int i = 0; i < n; ++i)
    {
        g[i].clear();
    }

    for (int i = 0; i < u.size(); ++i)
    {
        int x = u[i];
        int y = v[i];

        g[x].push_back(y);
        g[y].push_back(x);
    }

    hashed.clear();
    hashed.resize(n);

    tim = 0;

    dfs(0, -1);

    return hashed;
}

int find_next_station(int s, int t, vector<int> c)
{
    int in_s = s / 1000;
    int out_s = s % 1000;

    int in_t = t / 1000;
    int out_t = t % 1000;

    if (in_s <= in_t && out_t <= out_s)
    {
        int from = (in_s == 0 ? 0 : 1);

        for (int i = from; i < c.size(); ++i)
        {
            int in_i = c[i] / 1000;
            int out_i = c[i] % 1000;

            if (in_i <= in_t && out_t <= out_i)
            {
                return c[i];
            }
        }
    }

    return c[0];
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < g[node].size(); ++i)
      |                     ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < u.size(); ++i)
      |                     ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:68:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         for (int i = from; i < c.size(); ++i)
      |                            ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 444 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 388 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 441 ms 544 KB Output is correct
2 Correct 334 ms 624 KB Output is correct
3 Correct 600 ms 604 KB Output is correct
4 Correct 543 ms 528 KB Output is correct
5 Correct 481 ms 420 KB Output is correct
6 Correct 271 ms 572 KB Output is correct
7 Correct 469 ms 528 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 583 ms 532 KB Output is correct
12 Correct 415 ms 648 KB Output is correct
13 Correct 352 ms 644 KB Output is correct
14 Correct 338 ms 528 KB Output is correct
15 Correct 46 ms 552 KB Output is correct
16 Correct 39 ms 556 KB Output is correct
17 Correct 79 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 669 ms 420 KB Output is correct
2 Correct 569 ms 524 KB Output is correct
3 Correct 478 ms 524 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 437 ms 420 KB Output is correct
8 Correct 772 ms 532 KB Output is correct
9 Correct 592 ms 420 KB Output is correct
10 Correct 344 ms 532 KB Output is correct
11 Correct 5 ms 492 KB Output is correct
12 Correct 4 ms 500 KB Output is correct
13 Correct 3 ms 492 KB Output is correct
14 Correct 3 ms 492 KB Output is correct
15 Correct 0 ms 500 KB Output is correct
16 Correct 462 ms 524 KB Output is correct
17 Correct 428 ms 420 KB Output is correct
18 Correct 391 ms 528 KB Output is correct
19 Correct 424 ms 420 KB Output is correct
20 Correct 432 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 440 ms 656 KB Partially correct
2 Partially correct 423 ms 548 KB Partially correct
3 Partially correct 745 ms 416 KB Partially correct
4 Partially correct 506 ms 528 KB Partially correct
5 Partially correct 507 ms 528 KB Partially correct
6 Partially correct 361 ms 544 KB Partially correct
7 Partially correct 373 ms 528 KB Partially correct
8 Partially correct 2 ms 488 KB Partially correct
9 Partially correct 3 ms 492 KB Partially correct
10 Partially correct 0 ms 500 KB Partially correct
11 Partially correct 318 ms 528 KB Partially correct
12 Partially correct 486 ms 520 KB Partially correct
13 Partially correct 758 ms 420 KB Partially correct
14 Partially correct 511 ms 528 KB Partially correct
15 Partially correct 432 ms 416 KB Partially correct
16 Partially correct 311 ms 524 KB Partially correct
17 Partially correct 518 ms 464 KB Partially correct
18 Partially correct 434 ms 624 KB Partially correct
19 Partially correct 351 ms 656 KB Partially correct
20 Partially correct 325 ms 544 KB Partially correct
21 Partially correct 53 ms 600 KB Partially correct
22 Partially correct 67 ms 600 KB Partially correct
23 Partially correct 79 ms 576 KB Partially correct
24 Partially correct 4 ms 500 KB Partially correct
25 Partially correct 4 ms 488 KB Partially correct
26 Partially correct 3 ms 492 KB Partially correct
27 Partially correct 2 ms 492 KB Partially correct
28 Partially correct 1 ms 492 KB Partially correct
29 Partially correct 328 ms 528 KB Partially correct
30 Partially correct 520 ms 416 KB Partially correct
31 Partially correct 385 ms 484 KB Partially correct
32 Partially correct 360 ms 420 KB Partially correct
33 Partially correct 414 ms 544 KB Partially correct
34 Partially correct 232 ms 548 KB Partially correct
35 Partially correct 333 ms 692 KB Partially correct
36 Partially correct 360 ms 516 KB Partially correct
37 Partially correct 366 ms 632 KB Partially correct
38 Partially correct 449 ms 628 KB Partially correct
39 Partially correct 394 ms 656 KB Partially correct
40 Partially correct 298 ms 764 KB Partially correct
41 Partially correct 476 ms 640 KB Partially correct
42 Partially correct 46 ms 572 KB Partially correct
43 Partially correct 95 ms 548 KB Partially correct
44 Partially correct 108 ms 532 KB Partially correct
45 Partially correct 167 ms 628 KB Partially correct
46 Partially correct 263 ms 580 KB Partially correct
47 Partially correct 285 ms 508 KB Partially correct
48 Partially correct 66 ms 732 KB Partially correct
49 Partially correct 53 ms 760 KB Partially correct