Submission #413201

# Submission time Handle Problem Language Result Execution time Memory
413201 2021-05-28T11:06:02 Z losmi247 Stations (IOI20_stations) C++14
0 / 100
3000 ms 1073664 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1005;

int deg[N];
vector <int> g[N];



vector <int> label(int n,int k,vector <int> u,vector <int> v){
    for(int i = 0; i < n-1; i++){
        deg[u[i]]++, deg[v[i]]++;
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }


    bool prvi = 1;
    for(int i = 0; i < n; i++) if(deg[i] > 2) prvi = 0;
    if(prvi){
        int cnt = 0;
        vector <int> l;
        queue <pair<int,int>> q;
        for(int i = 0; i < n; i++){
            if(deg[i] == 1){
                q.push({i,0});
                break;
            }
        }
        while(!q.empty()){
            int u = q.front().first,par = q.front().second;
            l.push_back(cnt++);
            q.pop();
            for(auto v : g[u]){
                if(v == par) continue;
                q.push({v,u});
            }
        }
        return l;
    }
}

int find_next_station(int s,int t,vector <int> c){
    if(s < t){
        return s+1;
    }
    else{
        return s-1;
    }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Invalid length of array as the response of 'label'. scenario=1, n=3, len=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 304 KB Invalid length of array as the response of 'label'. scenario=1, n=994, len=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3070 ms 1051200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Invalid length of array as the response of 'label'. scenario=1, n=2, len=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3099 ms 1073664 KB Time limit exceeded
2 Halted 0 ms 0 KB -