Submission #320317

# Submission time Handle Problem Language Result Execution time Memory
320317 2020-11-08T09:48:51 Z nickmet2004 Stations (IOI20_stations) C++14
0 / 100
1043 ms 1168 KB
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
const int N = 1005;
vector<int> adj[N];
int dtime;
/// in-stvis unda vicode out-ebi , out-stvis in-ebi
void dfs(int u , int h , vector<int> &R ,int p ){
    if(!h) R[u]= dtime++; /// in
    for(int v : adj[u])if(v ^ p)dfs(v ,h^1 , R , u);
    if(h) R[u] = dtime++; /// out
}
vector<int> label(int n , int k ,vector<int> u , vector<int> v){
    for(int i = 0; i < n; ++i) adj[i].clear();
    for(int i = 0; i < n-1; ++i) adj[u[i]].emplace_back(v[i]) , adj[v[i]].emplace_back(u[i]);
    vector<int> R(n);
    dtime =0;
    dfs(0 , 0 , R ,-1);
    return R;
}
/// (in1 , out1) in = out0 + 1
/// (in0 , out0) out0 = in1 - 1;
int find_next_station(int s , int t , vector<int> c){
    /// s-in
    if(s < c[0]){
        int cur = s;
        for(int x: c){
            if(cur < t && t <= x) return x;
            cur = x;
        }
        return c.back(); /// parent
    } else {
        /// s out
        for(int i = 0; i < c.size(); ++i){
            if(i == c.size()) {if(c[i] <= t && t < s) return i; continue;}
            if(c[i] <= t && t < c[i + 1]) return c[i];
        }
    }/// parent
    return c[0];
}
/*
int main (){
    cin >> n;
    for(int i =1; i < n; ++i){
        int u , v; cin >> u>> v;
        adj[u].emplace_back(v); adj[v].emplace_back(u);
    }
    vector<int> k = label(n , 1 , {3} , {3});
    cout << find_next_station(1 , 3 , {3 , 2 ,0}) << endl;
}
*/
//int main (){}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i = 0; i < c.size(); ++i){
      |                        ~~^~~~~~~~~~
stations.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             if(i == c.size()) {if(c[i] <= t && t < s) return i; continue;}
      |                ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 522 ms 1072 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 447 ms 884 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 533 ms 1168 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1043 ms 948 KB Output is correct
2 Incorrect 706 ms 952 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 575 ms 1084 KB Wrong query response.
2 Halted 0 ms 0 KB -