Submission #431365

# Submission time Handle Problem Language Result Execution time Memory
431365 2021-06-17T11:23:15 Z idk321 Stations (IOI20_stations) C++17
52.3205 / 100
1226 ms 700 KB
#include "stations.h"
#include <vector>

using namespace std;

const int M = 1000000000;
const int N = 1000;
int in[N];
int out[N];
vector<int> adj[N];
vector<int> labels;

int n, k;

int timer;



void dfs2(int node, int par)
{
    timer++;
    in[node] = timer;

    for (int next : adj[node])
    {
        if (next == par) continue;
        dfs2(next, node);
    }

    out[node] = timer;
}





std::vector<int> label(int n1, int k1, std::vector<int> u, std::vector<int> v) {
    n = n1;
    k = k1;

	labels.assign(n, 0);


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




    timer = -1;
    dfs2(0, -1);



	for (int i = 0; i < n; i++) {
		labels[i] = in[i] * 1000 + out[i];
	}
	return labels;
}



int find_next_station(int s, int t, std::vector<int> c) {
    int sIn = s / 1000;
    int sOut = s % 1000;
    int tIn = t / 1000;
    int tOut = t % 1000;


    if (sIn <= tIn && tOut <= sOut)
    {
        for (int next : c)
        {
            int nextIn = next / 1000;
            int nextOut = next % 1000;
            if (!(nextIn <= sIn && sOut <= nextOut) && (nextIn <= tIn && tOut <= nextOut)) return next;
        }
    } else
    {
        for (int next : c)
        {
            int nextIn = next / 1000;
            int nextOut = next % 1000;
            if (nextIn <= sIn && sOut <= nextOut) return next;
        }
    }



	return c[0];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:45:23: 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 = 0; i < u.size(); i++)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 328 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 9 ms 296 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 742 ms 640 KB Output is correct
2 Correct 670 ms 480 KB Output is correct
3 Correct 1226 ms 484 KB Output is correct
4 Correct 723 ms 488 KB Output is correct
5 Correct 662 ms 496 KB Output is correct
6 Correct 488 ms 500 KB Output is correct
7 Correct 562 ms 500 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 775 ms 400 KB Output is correct
12 Correct 492 ms 692 KB Output is correct
13 Correct 541 ms 652 KB Output is correct
14 Correct 523 ms 500 KB Output is correct
15 Correct 61 ms 524 KB Output is correct
16 Correct 68 ms 496 KB Output is correct
17 Correct 114 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 945 ms 480 KB Output is correct
2 Correct 805 ms 480 KB Output is correct
3 Correct 738 ms 400 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 760 ms 400 KB Output is correct
8 Correct 893 ms 488 KB Output is correct
9 Correct 670 ms 496 KB Output is correct
10 Correct 693 ms 504 KB Output is correct
11 Correct 7 ms 432 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Correct 4 ms 448 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 599 ms 512 KB Output is correct
17 Correct 644 ms 476 KB Output is correct
18 Correct 719 ms 480 KB Output is correct
19 Correct 502 ms 496 KB Output is correct
20 Correct 569 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 544 ms 528 KB Partially correct
2 Partially correct 436 ms 488 KB Partially correct
3 Partially correct 843 ms 400 KB Partially correct
4 Partially correct 686 ms 400 KB Partially correct
5 Partially correct 581 ms 492 KB Partially correct
6 Partially correct 524 ms 520 KB Partially correct
7 Partially correct 475 ms 492 KB Partially correct
8 Partially correct 3 ms 448 KB Partially correct
9 Partially correct 7 ms 496 KB Partially correct
10 Partially correct 3 ms 468 KB Partially correct
11 Partially correct 465 ms 476 KB Partially correct
12 Partially correct 593 ms 520 KB Partially correct
13 Partially correct 901 ms 480 KB Partially correct
14 Partially correct 676 ms 476 KB Partially correct
15 Partially correct 612 ms 508 KB Partially correct
16 Partially correct 446 ms 492 KB Partially correct
17 Partially correct 629 ms 496 KB Partially correct
18 Partially correct 488 ms 588 KB Partially correct
19 Partially correct 569 ms 596 KB Partially correct
20 Partially correct 528 ms 480 KB Partially correct
21 Partially correct 66 ms 400 KB Partially correct
22 Partially correct 72 ms 544 KB Partially correct
23 Partially correct 110 ms 692 KB Partially correct
24 Partially correct 5 ms 400 KB Partially correct
25 Partially correct 8 ms 468 KB Partially correct
26 Partially correct 3 ms 400 KB Partially correct
27 Partially correct 3 ms 468 KB Partially correct
28 Partially correct 2 ms 468 KB Partially correct
29 Partially correct 609 ms 516 KB Partially correct
30 Partially correct 591 ms 496 KB Partially correct
31 Partially correct 536 ms 488 KB Partially correct
32 Partially correct 559 ms 496 KB Partially correct
33 Partially correct 500 ms 560 KB Partially correct
34 Partially correct 386 ms 556 KB Partially correct
35 Partially correct 510 ms 604 KB Partially correct
36 Partially correct 454 ms 568 KB Partially correct
37 Partially correct 488 ms 660 KB Partially correct
38 Partially correct 493 ms 584 KB Partially correct
39 Partially correct 554 ms 572 KB Partially correct
40 Partially correct 515 ms 580 KB Partially correct
41 Partially correct 486 ms 700 KB Partially correct
42 Partially correct 63 ms 640 KB Partially correct
43 Partially correct 118 ms 580 KB Partially correct
44 Partially correct 170 ms 500 KB Partially correct
45 Partially correct 201 ms 592 KB Partially correct
46 Partially correct 366 ms 536 KB Partially correct
47 Partially correct 395 ms 568 KB Partially correct
48 Partially correct 72 ms 528 KB Partially correct
49 Partially correct 61 ms 656 KB Partially correct