Submission #768092

# Submission time Handle Problem Language Result Execution time Memory
768092 2023-06-27T12:54:23 Z 3RR0R404 Stations (IOI20_stations) C++14
0 / 100
1 ms 556 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> child(1000,0);
int l=0;
set<int> visited;
int dfs(int node,int d,vector<int> L,vector<vector<int>> adj)
{
    visited.insert(node);
    L[node] = l;
    l++;
    int b=0;
    for(auto p: adj[node])
    {
        if(visited.find(p)==visited.end())
        {
            continue;
        }
        child[d] += dfs(p,l,L,adj);
    }
    return child[d]+1;
}
vector<int> label(int n,int k,vector<int> u,vector<int> v)
{
    vector<vector<int>> adj(n);
    for(int i=0;i<n-1,i++;)
    {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    vector<int> L(n,0);

    for(auto i: adj)
    {
        if(i.size() == 1);
        {  
            dfs(i[0],0,L,adj);
        }
        break;
    }
    return L;
}
int find_next_station(int s, int t, vector<int> c)
{
    sort(c.begin(),c.end());
    if(s+child[s]<t)
    {
        return c[0];
    }
    if(s>t)
    {
        return c[0];
    }
    return *(upper_bound(c.begin(),c.end(),t)-1);
}

Compilation message

stations.cpp: In function 'int dfs(int, int, std::vector<int>, std::vector<std::vector<int> >)':
stations.cpp:11:9: warning: unused variable 'b' [-Wunused-variable]
   11 |     int b=0;
      |         ^
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:18: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |     for(int i=0;i<n-1,i++;)
      |                 ~^~~~
stations.cpp:34:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   34 |         if(i.size() == 1);
      |         ^~
stations.cpp:35:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   35 |         {
      |         ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 556 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -