Submission #349795

# Submission time Handle Problem Language Result Execution time Memory
349795 2021-01-18T12:13:56 Z blue Stations (IOI20_stations) C++17
100 / 100
989 ms 1232 KB
#include "stations.h"
#include <iostream>
#include <vector>
using namespace std;
 
vector<int> edge[1000];
vector<int> visit(1000, 0);
vector<int> L;
 
int dfs(int u, int a, bool flag) //vertex, minimum label, left/right?     return largest unused label
{
    visit[u] = 1;
 
    if(flag == 0)
    {
        L[u] = a;
        a++;
    }
 
    for(int v: edge[u])
    {
        if(visit[v]) continue;
        a = dfs(v, a, !flag);
    }
 
    if(flag == 1)
    {
        L[u] = a;
        a++;
    }
 
    return a;
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
    for(int i = 0; i < n; i++) 
    {
      edge[i].clear();
      visit[i] = 0;
    }
  
  
    for(int j = 0; j < n-1; j++)
    {
        edge[u[j]].push_back(v[j]);
        edge[v[j]].push_back(u[j]);
    }
 
    L = vector<int>(n, -1);
 
    dfs(0, 0, 0);
 
    return L;
}
 
int find_next_station(int s, int t, vector<int> c)
{
    if(s < c[0]) // s is left label
    {
        if(t < s) return c[c.size()-1];
        for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
        return c[c.size()-1];
    }
    else // s is right label
    {
        if(t > s) return c[0];
        for(int i = c.size()-1; i >= 0; i--) if(t >= c[i]) return c[i];
        return c[0];
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:62:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 511 ms 1228 KB Output is correct
2 Correct 502 ms 1096 KB Output is correct
3 Correct 927 ms 992 KB Output is correct
4 Correct 689 ms 992 KB Output is correct
5 Correct 569 ms 992 KB Output is correct
6 Correct 428 ms 1076 KB Output is correct
7 Correct 461 ms 864 KB Output is correct
8 Correct 3 ms 956 KB Output is correct
9 Correct 6 ms 884 KB Output is correct
10 Correct 1 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 454 ms 864 KB Output is correct
2 Correct 574 ms 864 KB Output is correct
3 Correct 915 ms 1076 KB Output is correct
4 Correct 772 ms 948 KB Output is correct
5 Correct 614 ms 956 KB Output is correct
6 Correct 430 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 571 ms 992 KB Output is correct
2 Correct 537 ms 1096 KB Output is correct
3 Correct 940 ms 864 KB Output is correct
4 Correct 721 ms 736 KB Output is correct
5 Correct 677 ms 948 KB Output is correct
6 Correct 480 ms 1232 KB Output is correct
7 Correct 503 ms 864 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 5 ms 816 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 622 ms 864 KB Output is correct
12 Correct 509 ms 864 KB Output is correct
13 Correct 459 ms 1104 KB Output is correct
14 Correct 560 ms 864 KB Output is correct
15 Correct 69 ms 940 KB Output is correct
16 Correct 62 ms 992 KB Output is correct
17 Correct 130 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 989 ms 948 KB Output is correct
2 Correct 621 ms 948 KB Output is correct
3 Correct 623 ms 1108 KB Output is correct
4 Correct 3 ms 956 KB Output is correct
5 Correct 5 ms 864 KB Output is correct
6 Correct 2 ms 864 KB Output is correct
7 Correct 656 ms 864 KB Output is correct
8 Correct 895 ms 992 KB Output is correct
9 Correct 671 ms 736 KB Output is correct
10 Correct 717 ms 864 KB Output is correct
11 Correct 6 ms 996 KB Output is correct
12 Correct 7 ms 864 KB Output is correct
13 Correct 6 ms 864 KB Output is correct
14 Correct 5 ms 864 KB Output is correct
15 Correct 2 ms 948 KB Output is correct
16 Correct 517 ms 736 KB Output is correct
17 Correct 487 ms 992 KB Output is correct
18 Correct 534 ms 956 KB Output is correct
19 Correct 476 ms 992 KB Output is correct
20 Correct 539 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 512 ms 992 KB Output is correct
2 Correct 451 ms 1108 KB Output is correct
3 Correct 940 ms 992 KB Output is correct
4 Correct 700 ms 864 KB Output is correct
5 Correct 564 ms 1108 KB Output is correct
6 Correct 567 ms 1104 KB Output is correct
7 Correct 438 ms 864 KB Output is correct
8 Correct 3 ms 956 KB Output is correct
9 Correct 5 ms 948 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 467 ms 992 KB Output is correct
12 Correct 507 ms 884 KB Output is correct
13 Correct 877 ms 948 KB Output is correct
14 Correct 680 ms 864 KB Output is correct
15 Correct 535 ms 948 KB Output is correct
16 Correct 454 ms 896 KB Output is correct
17 Correct 546 ms 948 KB Output is correct
18 Correct 470 ms 1112 KB Output is correct
19 Correct 444 ms 1096 KB Output is correct
20 Correct 430 ms 896 KB Output is correct
21 Correct 70 ms 940 KB Output is correct
22 Correct 63 ms 912 KB Output is correct
23 Correct 98 ms 1116 KB Output is correct
24 Correct 6 ms 864 KB Output is correct
25 Correct 5 ms 948 KB Output is correct
26 Correct 4 ms 736 KB Output is correct
27 Correct 4 ms 864 KB Output is correct
28 Correct 2 ms 996 KB Output is correct
29 Correct 480 ms 736 KB Output is correct
30 Correct 492 ms 864 KB Output is correct
31 Correct 471 ms 1108 KB Output is correct
32 Correct 502 ms 948 KB Output is correct
33 Correct 487 ms 948 KB Output is correct
34 Correct 319 ms 1108 KB Output is correct
35 Correct 415 ms 1120 KB Output is correct
36 Correct 463 ms 864 KB Output is correct
37 Correct 418 ms 864 KB Output is correct
38 Correct 548 ms 1008 KB Output is correct
39 Correct 527 ms 944 KB Output is correct
40 Correct 553 ms 1012 KB Output is correct
41 Correct 565 ms 1016 KB Output is correct
42 Correct 78 ms 864 KB Output is correct
43 Correct 141 ms 864 KB Output is correct
44 Correct 133 ms 864 KB Output is correct
45 Correct 179 ms 1004 KB Output is correct
46 Correct 319 ms 896 KB Output is correct
47 Correct 287 ms 864 KB Output is correct
48 Correct 67 ms 992 KB Output is correct
49 Correct 56 ms 992 KB Output is correct