Submission #784835

# Submission time Handle Problem Language Result Execution time Memory
784835 2023-07-16T15:10:24 Z lucri Stations (IOI20_stations) C++17
100 / 100
832 ms 792 KB
#include "stations.h"
#include <bits/stdc++.h>
std::vector<std::vector<int>>a;;
std::vector<int>ins,outs,code;
int cur;
void pleaca(int nod,int t,bool act,std::vector<std::vector<int>> &a,std::vector<int> &cod)
{
    ins[nod]=cur++;
    for(auto x:a[nod])
    {
        if(x!=t)
            pleaca(x,nod,!act,a,cod);
    }
    outs[nod]=cur++;
    if(act==0)
        cod[nod]=ins[nod];
    else
        cod[nod]=outs[nod];
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	a.clear();
	ins.clear();
	outs.clear();
	code.clear();
	a.resize(n+5);
	ins.resize(n+5);
	outs.resize(n+5);
	code.resize(2*n+5);
	cur=0;
	for(int i=0;i<n-1;++i)
    {
        a[u[i]].push_back(v[i]);
        a[v[i]].push_back(u[i]);
    }
	pleaca(0,-1,0,a,labels);
	for(int i=0;i<n;++i)
        ++code[labels[i]];
	for(int i=1;i<2*n;++i)
        code[i]+=code[i-1];
	for(int i=0;i<n;++i)
        labels[i]=code[labels[i]];
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    int ans=c.size();
    --ans;
    if(c[0]<s)
    {
        if(t>s||t<=c[0])
            return c[0];
        while(c[ans]>t)
            --ans;
        return c[ans];
    }
    if(s!=1)
        if(t<s||t>=c[ans])
            return c[ans];
    ans=0;
    while(c[ans]<t)
        ++ans;
    return c[ans];
}
# Verdict Execution time Memory Grader output
1 Correct 411 ms 676 KB Output is correct
2 Correct 292 ms 676 KB Output is correct
3 Correct 760 ms 416 KB Output is correct
4 Correct 433 ms 480 KB Output is correct
5 Correct 516 ms 416 KB Output is correct
6 Correct 360 ms 640 KB Output is correct
7 Correct 414 ms 616 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 0 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 429 ms 544 KB Output is correct
2 Correct 379 ms 548 KB Output is correct
3 Correct 648 ms 416 KB Output is correct
4 Correct 492 ms 504 KB Output is correct
5 Correct 483 ms 508 KB Output is correct
6 Correct 394 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 461 ms 676 KB Output is correct
2 Correct 330 ms 668 KB Output is correct
3 Correct 607 ms 420 KB Output is correct
4 Correct 648 ms 420 KB Output is correct
5 Correct 516 ms 508 KB Output is correct
6 Correct 358 ms 676 KB Output is correct
7 Correct 394 ms 628 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 5 ms 568 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 540 ms 416 KB Output is correct
12 Correct 399 ms 792 KB Output is correct
13 Correct 438 ms 756 KB Output is correct
14 Correct 470 ms 628 KB Output is correct
15 Correct 48 ms 576 KB Output is correct
16 Correct 51 ms 620 KB Output is correct
17 Correct 93 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 777 ms 508 KB Output is correct
2 Correct 605 ms 500 KB Output is correct
3 Correct 429 ms 416 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 1 ms 576 KB Output is correct
7 Correct 451 ms 416 KB Output is correct
8 Correct 681 ms 488 KB Output is correct
9 Correct 495 ms 508 KB Output is correct
10 Correct 406 ms 504 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 4 ms 500 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 445 ms 420 KB Output is correct
17 Correct 464 ms 508 KB Output is correct
18 Correct 432 ms 512 KB Output is correct
19 Correct 370 ms 416 KB Output is correct
20 Correct 434 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 378 ms 704 KB Output is correct
2 Correct 338 ms 676 KB Output is correct
3 Correct 832 ms 612 KB Output is correct
4 Correct 570 ms 416 KB Output is correct
5 Correct 489 ms 416 KB Output is correct
6 Correct 307 ms 636 KB Output is correct
7 Correct 363 ms 612 KB Output is correct
8 Correct 1 ms 580 KB Output is correct
9 Correct 2 ms 500 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 369 ms 544 KB Output is correct
12 Correct 418 ms 508 KB Output is correct
13 Correct 657 ms 480 KB Output is correct
14 Correct 556 ms 508 KB Output is correct
15 Correct 441 ms 508 KB Output is correct
16 Correct 391 ms 544 KB Output is correct
17 Correct 427 ms 420 KB Output is correct
18 Correct 377 ms 624 KB Output is correct
19 Correct 401 ms 712 KB Output is correct
20 Correct 409 ms 548 KB Output is correct
21 Correct 61 ms 444 KB Output is correct
22 Correct 49 ms 544 KB Output is correct
23 Correct 100 ms 548 KB Output is correct
24 Correct 5 ms 492 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 439 ms 500 KB Output is correct
30 Correct 441 ms 500 KB Output is correct
31 Correct 442 ms 416 KB Output is correct
32 Correct 469 ms 420 KB Output is correct
33 Correct 343 ms 496 KB Output is correct
34 Correct 228 ms 672 KB Output is correct
35 Correct 404 ms 692 KB Output is correct
36 Correct 393 ms 640 KB Output is correct
37 Correct 387 ms 536 KB Output is correct
38 Correct 317 ms 536 KB Output is correct
39 Correct 295 ms 712 KB Output is correct
40 Correct 340 ms 704 KB Output is correct
41 Correct 468 ms 560 KB Output is correct
42 Correct 48 ms 600 KB Output is correct
43 Correct 84 ms 608 KB Output is correct
44 Correct 82 ms 500 KB Output is correct
45 Correct 162 ms 508 KB Output is correct
46 Correct 270 ms 548 KB Output is correct
47 Correct 284 ms 760 KB Output is correct
48 Correct 51 ms 508 KB Output is correct
49 Correct 44 ms 672 KB Output is correct