Submission #367196

# Submission time Handle Problem Language Result Execution time Memory
367196 2021-02-16T14:12:39 Z rumen_m Stations (IOI20_stations) C++17
100 / 100
1152 ms 1208 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
std::vector<int> labelss;
vector <int> g[maxn];
int id;
void dfs(int v, bool level, int par)
{
   // cout<<v<<" "<<level<<endl;
    if(level==1)
    {
        id++;
        labelss[v] = id;
    }
    int u;
    int i;
    for(i = 0; i<g[v].size();i++)
    {
        u = g[v][i];
        if(u==par)continue;
       // cout<<v<<"->"<<u<<endl;
        dfs(u,!level,v);
    }
    if(level==0)
    {
        id++;
        labelss[v] = id;
    }
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	labelss.clear();
	labelss.resize(n);
	int i;
	for(i=0;i<n;i++)
        g[i].clear();

	for(i=0;i<n-1;i++)
    {
       // cout<<v[i]<<"&&"<<u[i]<<endl;
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }// cout<<"OJK"<<endl;
    id = 0;
    dfs(0,1,-1);
   // for(i=0;i<n;i++)
   // //    cout<<labelss[i]<<" ";
   // cout<<endl;
    return labelss;
}

int find_next_station(int s, int t, std::vector<int> c) {
    sort(c.begin(),c.end());
    int k  =c.size();
    if(s<c[0])
    {
        if(t<=s)return c[k-1];
        int i;
        for(i=0;i<k;i++)
        {
            if(t<=c[i])return c[i];
        }
        return c[k-1];
    }
    else
    {
        if(t>=s)return c[0];
        int i;
        for(i=1;i<k;i++)
        {
            if(t<c[i])return c[i-1];
        }
        return c[k-1];
    }
	//return c[0];
}

Compilation message

stations.cpp: In function 'void dfs(int, bool, int)':
stations.cpp:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(i = 0; i<g[v].size();i++)
      |                ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 657 ms 1076 KB Output is correct
2 Correct 548 ms 1072 KB Output is correct
3 Correct 955 ms 1024 KB Output is correct
4 Correct 685 ms 864 KB Output is correct
5 Correct 677 ms 952 KB Output is correct
6 Correct 452 ms 1084 KB Output is correct
7 Correct 527 ms 992 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 5 ms 776 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 555 ms 884 KB Output is correct
2 Correct 509 ms 892 KB Output is correct
3 Correct 1152 ms 960 KB Output is correct
4 Correct 784 ms 992 KB Output is correct
5 Correct 623 ms 864 KB Output is correct
6 Correct 532 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 675 ms 1024 KB Output is correct
2 Correct 582 ms 992 KB Output is correct
3 Correct 1015 ms 864 KB Output is correct
4 Correct 755 ms 784 KB Output is correct
5 Correct 661 ms 864 KB Output is correct
6 Correct 533 ms 1024 KB Output is correct
7 Correct 500 ms 992 KB Output is correct
8 Correct 3 ms 952 KB Output is correct
9 Correct 4 ms 952 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
11 Correct 713 ms 736 KB Output is correct
12 Correct 517 ms 1208 KB Output is correct
13 Correct 552 ms 1004 KB Output is correct
14 Correct 494 ms 864 KB Output is correct
15 Correct 73 ms 944 KB Output is correct
16 Correct 81 ms 864 KB Output is correct
17 Correct 113 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 873 ms 992 KB Output is correct
2 Correct 764 ms 1108 KB Output is correct
3 Correct 615 ms 952 KB Output is correct
4 Correct 3 ms 952 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 1 ms 864 KB Output is correct
7 Correct 682 ms 864 KB Output is correct
8 Correct 949 ms 952 KB Output is correct
9 Correct 737 ms 952 KB Output is correct
10 Correct 607 ms 1080 KB Output is correct
11 Correct 6 ms 952 KB Output is correct
12 Correct 7 ms 952 KB Output is correct
13 Correct 5 ms 960 KB Output is correct
14 Correct 4 ms 952 KB Output is correct
15 Correct 2 ms 864 KB Output is correct
16 Correct 543 ms 992 KB Output is correct
17 Correct 592 ms 1108 KB Output is correct
18 Correct 535 ms 1108 KB Output is correct
19 Correct 626 ms 952 KB Output is correct
20 Correct 558 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 645 ms 1072 KB Output is correct
2 Correct 519 ms 1080 KB Output is correct
3 Correct 1095 ms 952 KB Output is correct
4 Correct 719 ms 736 KB Output is correct
5 Correct 652 ms 864 KB Output is correct
6 Correct 513 ms 1024 KB Output is correct
7 Correct 527 ms 992 KB Output is correct
8 Correct 3 ms 772 KB Output is correct
9 Correct 4 ms 864 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
11 Correct 534 ms 736 KB Output is correct
12 Correct 526 ms 736 KB Output is correct
13 Correct 1061 ms 864 KB Output is correct
14 Correct 776 ms 952 KB Output is correct
15 Correct 752 ms 864 KB Output is correct
16 Correct 572 ms 900 KB Output is correct
17 Correct 694 ms 784 KB Output is correct
18 Correct 491 ms 1120 KB Output is correct
19 Correct 567 ms 1024 KB Output is correct
20 Correct 569 ms 900 KB Output is correct
21 Correct 59 ms 760 KB Output is correct
22 Correct 83 ms 736 KB Output is correct
23 Correct 96 ms 736 KB Output is correct
24 Correct 5 ms 736 KB Output is correct
25 Correct 6 ms 1000 KB Output is correct
26 Correct 5 ms 736 KB Output is correct
27 Correct 4 ms 952 KB Output is correct
28 Correct 2 ms 776 KB Output is correct
29 Correct 587 ms 1012 KB Output is correct
30 Correct 592 ms 864 KB Output is correct
31 Correct 520 ms 736 KB Output is correct
32 Correct 506 ms 992 KB Output is correct
33 Correct 559 ms 952 KB Output is correct
34 Correct 333 ms 1084 KB Output is correct
35 Correct 503 ms 1064 KB Output is correct
36 Correct 508 ms 1080 KB Output is correct
37 Correct 563 ms 1108 KB Output is correct
38 Correct 538 ms 1108 KB Output is correct
39 Correct 544 ms 1104 KB Output is correct
40 Correct 456 ms 1104 KB Output is correct
41 Correct 580 ms 1112 KB Output is correct
42 Correct 63 ms 864 KB Output is correct
43 Correct 110 ms 736 KB Output is correct
44 Correct 132 ms 804 KB Output is correct
45 Correct 191 ms 816 KB Output is correct
46 Correct 358 ms 932 KB Output is correct
47 Correct 349 ms 992 KB Output is correct
48 Correct 77 ms 992 KB Output is correct
49 Correct 56 ms 992 KB Output is correct