Submission #850580

# Submission time Handle Problem Language Result Execution time Memory
850580 2023-09-17T00:51:31 Z abcvuitunggio Stations (IOI20_stations) C++17
100 / 100
596 ms 1520 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> ke[1001],ve,V;
int t,tin[1001],tout[1001],d[1001];
void dfs(int u, int p){
    tin[u]=++t;
    for (int v:ke[u])
        if (v!=p){
            d[v]=d[u]+1;
            dfs(v,u);
        }
    tout[u]=++t;
}
vector <int> label(int n, int k, vector <int> u, vector <int> v){
    V.clear();
    ve.clear();
	for (int i=0;i<n-1;i++){
        ke[u[i]].push_back(v[i]);
        ke[v[i]].push_back(u[i]);
	}
	dfs(0,0);
	for (int i=0;i<n;i++)
        if (d[i]%2==0)
            V.push_back(tin[i]);
        else
            V.push_back(tout[i]);
    sort(V.begin(),V.end());
    for (int i=0;i<n;i++){
        int val=(d[i]%2?tout[i]:tin[i]);
        ve.push_back(lower_bound(V.begin(),V.end(),val)-V.begin()+1);
    }
    for (int i=0;i<n;i++)
        ke[i].clear();
    t=0;
	return ve;
}

int find_next_station(int s, int t, vector <int> c){
    for (int i:c)
        if (i==t)
            return i;
    if (c.size()==1)
        return c[0];
    if (s<c[0]){
        int tout=c[c.size()-2];
        if (t>tout||t<s)
            return c.back();
        c.pop_back();
        for (int i:c)
            if (t<i)
                return i;
    }
    if (t<c[1]||t>s)
        return c[0];
    for (int i=c.size()-1;i;i--)
        if (t>c[i])
            return c[i];
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 369 ms 936 KB Output is correct
2 Correct 331 ms 940 KB Output is correct
3 Correct 589 ms 684 KB Output is correct
4 Correct 445 ms 684 KB Output is correct
5 Correct 395 ms 684 KB Output is correct
6 Correct 292 ms 920 KB Output is correct
7 Correct 316 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 884 KB Output is correct
2 Correct 308 ms 828 KB Output is correct
3 Correct 582 ms 684 KB Output is correct
4 Correct 403 ms 684 KB Output is correct
5 Correct 385 ms 684 KB Output is correct
6 Correct 294 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 354 ms 1108 KB Output is correct
2 Correct 332 ms 976 KB Output is correct
3 Correct 592 ms 684 KB Output is correct
4 Correct 450 ms 684 KB Output is correct
5 Correct 397 ms 688 KB Output is correct
6 Correct 304 ms 936 KB Output is correct
7 Correct 275 ms 936 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 1024 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 377 ms 864 KB Output is correct
12 Correct 291 ms 1240 KB Output is correct
13 Correct 301 ms 1036 KB Output is correct
14 Correct 268 ms 940 KB Output is correct
15 Correct 31 ms 764 KB Output is correct
16 Correct 35 ms 948 KB Output is correct
17 Correct 57 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 562 ms 684 KB Output is correct
2 Correct 435 ms 936 KB Output is correct
3 Correct 432 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 0 ms 1024 KB Output is correct
7 Correct 393 ms 1020 KB Output is correct
8 Correct 541 ms 684 KB Output is correct
9 Correct 418 ms 684 KB Output is correct
10 Correct 368 ms 684 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 2 ms 764 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 338 ms 940 KB Output is correct
17 Correct 331 ms 684 KB Output is correct
18 Correct 357 ms 684 KB Output is correct
19 Correct 346 ms 684 KB Output is correct
20 Correct 356 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 357 ms 928 KB Output is correct
2 Correct 298 ms 1228 KB Output is correct
3 Correct 546 ms 684 KB Output is correct
4 Correct 465 ms 684 KB Output is correct
5 Correct 409 ms 684 KB Output is correct
6 Correct 290 ms 936 KB Output is correct
7 Correct 300 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 912 KB Output is correct
11 Correct 274 ms 884 KB Output is correct
12 Correct 378 ms 852 KB Output is correct
13 Correct 596 ms 684 KB Output is correct
14 Correct 408 ms 684 KB Output is correct
15 Correct 385 ms 684 KB Output is correct
16 Correct 283 ms 684 KB Output is correct
17 Correct 402 ms 688 KB Output is correct
18 Correct 290 ms 1044 KB Output is correct
19 Correct 328 ms 1408 KB Output is correct
20 Correct 300 ms 684 KB Output is correct
21 Correct 36 ms 768 KB Output is correct
22 Correct 38 ms 912 KB Output is correct
23 Correct 59 ms 1140 KB Output is correct
24 Correct 2 ms 768 KB Output is correct
25 Correct 4 ms 764 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 322 ms 936 KB Output is correct
30 Correct 356 ms 684 KB Output is correct
31 Correct 311 ms 684 KB Output is correct
32 Correct 351 ms 684 KB Output is correct
33 Correct 316 ms 684 KB Output is correct
34 Correct 192 ms 916 KB Output is correct
35 Correct 262 ms 1172 KB Output is correct
36 Correct 321 ms 1036 KB Output is correct
37 Correct 337 ms 1172 KB Output is correct
38 Correct 307 ms 1164 KB Output is correct
39 Correct 311 ms 1180 KB Output is correct
40 Correct 309 ms 1520 KB Output is correct
41 Correct 297 ms 1156 KB Output is correct
42 Correct 36 ms 1164 KB Output is correct
43 Correct 61 ms 924 KB Output is correct
44 Correct 83 ms 1152 KB Output is correct
45 Correct 99 ms 900 KB Output is correct
46 Correct 177 ms 880 KB Output is correct
47 Correct 173 ms 900 KB Output is correct
48 Correct 36 ms 1436 KB Output is correct
49 Correct 31 ms 1508 KB Output is correct