Submission #364784

# Submission time Handle Problem Language Result Execution time Memory
364784 2021-02-10T03:24:31 Z leinad2 Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[1010];
int in[1010], out[1010], cnt;
void dfs(int v, int par)
{
    in[v]=++cnt;
    for(int i=0;i<adj[v].size();i++)
    {
        int p=adj[v][i];
        if(p!=par)dfs(p, v);
    }
    out[v]=cnt;
}
vector<int>label(int n, int k, vector<int>u, vector<int>v)
{
	for(int i=0;i<u.size();i++)
    {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    dfs(0, -1);
    vector<int>ans;
    for(int i=0;i<n;i++)ans.push_back(in[i]*1000+out[i]-1001);
    return ans;
}
int find_next_station(int s, int t, vector<int>c)
{
    int aa=s/1000;
    int bb=s%1000;
    int cc=t/1000;
    int dd=t%1000;
    if(cc<=aa&&bb<=dd||bb<cc||dd<aa)
    {
        for(int i=0;i<c.size();i++)
        {
            int ee=c[i]/1000;
            int ff=c[i]%1000;
            if(ee<=aa&&bb<=ff)return c[i];
        }
    }
    for(int i=0;i<c.size();i++)
    {
        int ee=c[i]/1000;
        int ff=c[i]%1000;
        if(ee<=cc&&dd<=ff&&!(ee<=aa&&bb<=ff))return c[i];
    }
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<adj[v].size();i++)
      |                 ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<u.size();i++)
      |              ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:14: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   34 |     if(cc<=aa&&bb<=dd||bb<cc||dd<aa)
      |        ~~~~~~^~~~~~~~
stations.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i=0;i<c.size();i++)
      |                     ~^~~~~~~~~
stations.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i=0;i<c.size();i++)
      |                 ~^~~~~~~~~
stations.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 2250 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3015 ms 616 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1708 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 968 ms 864 KB Output is correct
2 Runtime error 1317 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3015 ms 2097156 KB Time limit exceeded
2 Halted 0 ms 0 KB -