Submission #480000

# Submission time Handle Problem Language Result Execution time Memory
480000 2021-10-14T08:25:24 Z stefantaga Stations (IOI20_stations) C++14
0 / 100
1047 ms 660 KB
#include "stations.h"
#include <cstdio>
#include <cassert>
#include <map>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int viz[1505],nr;
vector <int> gr[1505];
void dfs(int x,int tata)
{
    viz[x]=nr;
    nr++;
    for (int i=0;i<gr[x].size();i++)
    {
        if (gr[x][i]!=tata)
        {
            dfs(gr[x][i],x);
        }
    }
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	for (int i=0;i<n;i++)
    {
        viz[i]=0;
        gr[i].clear();
    }
	for (int i=0;i<n-1;i++)
    {
        gr[u[i]].push_back(v[i]);
        gr[v[i]].push_back(u[i]);
    }
    nr=0;
    dfs(0,-1);
    for (int i=0;i<n;i++)
    {
        labels[i]=viz[i];
    }
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    if (c.size()==1)
    {
        return c[0];
    }
    for (int i=0;i<c.size();i++)
    {
        cout<<c[i]<<" ";
    }
    cout<<'\n';
    int i;
    if (s==0)
    {
        for (i=0;i<c.size()-1;i++)
        {
            if (c[i]<=t&&t<c[i+1])
            {
                return c[i];
            }
        }
        return c[c.size()-1];
    }
	else
    {
        if (!(c[1]<=t&&t<=c[c.size()-1]))
        {
            return c[0];
        }
        for (i=1;i<c.size()-1;i++)
        {
            if (c[i]<=t&&t<c[i+1])
            {
                return c[i];
            }
        }
        return c[c.size()-1];
    }
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i=0;i<gr[x].size();i++)
      |                  ~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for (int i=0;i<c.size();i++)
      |                  ~^~~~~~~~~
stations.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (i=0;i<c.size()-1;i++)
      |                  ~^~~~~~~~~~~
stations.cpp:72:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for (i=1;i<c.size()-1;i++)
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 44 ms 656 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 33 ms 660 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 47 ms 656 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1047 ms 656 KB Output is correct
2 Execution timed out 129 ms 656 KB Time limit exceeded (wall clock)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 46 ms 656 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -