Submission #419149

# Submission time Handle Problem Language Result Execution time Memory
419149 2021-06-06T13:35:14 Z NintsiChkhaidze Stations (IOI20_stations) C++14
0 / 100
881 ms 788 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector <int> vec[1005];
int cnt,in[1005],out[1005],O[2005];
bool q=0;
void dfs(int x,int p){
    in[x] = ++cnt;
    for (int j=0;j<vec[x].size();j++){
        int to = vec[x][j];
        if (to == p) continue;
        dfs(to,x);
    }
    out[x] = cnt;
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    q=0;
    if (k <= 1000000){
        q=1;
        vector<int> labels;
        for (int i=0;i<n;i++)
            labels.pb(i);
        return labels;
    }
    vector<int> labels;
    for (int i=0;i<1001;i++){
        O[i] = 0;
        vec[i].clear();
        in[i] = out[i] = 0;
    }
    for (int i=0;i<u.size();i++){
        vec[u[i]].pb(v[i]);
        vec[v[i]].pb(u[i]);
    }
    
    cnt=0;
    dfs(0,0);
    for (int i=0;i<n;i++)
        labels.pb(in[i]),O[in[i]] = out[i];
    
    return labels;
}
int find_next_station(int s, int t, vector<int> c) {
    if (q){
        if (c[0] == t) return t;
        if (c.size() > 1 && c[1] == t) return t;
    }
    int Ins = s,Int = t,Out = O[t];
    if (Ins < Int){
        for (int i=1;i<c.size();i++)
            if (Int >= c[i] && O[c[i]] >= Out) return c[i];
    }
    return c[0];
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int j=0;j<vec[x].size();j++){
      |                  ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i=0;i<u.size();i++){
      |                  ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for (int i=1;i<c.size();i++)
      |                      ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 612 ms 512 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 518 ms 512 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 655 ms 564 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 881 ms 400 KB Output is correct
2 Correct 742 ms 528 KB Output is correct
3 Incorrect 784 ms 512 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 616 ms 788 KB Wrong query response.
2 Halted 0 ms 0 KB -