Submission #320318

# Submission time Handle Problem Language Result Execution time Memory
320318 2020-11-08T09:54:53 Z nickmet2004 Stations (IOI20_stations) C++14
0 / 100
916 ms 1036 KB
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
vector<int> adj[1005];
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++;
    for(int v : adj[u])if(v != p)dfs(v ,h^1 , R , u);
    if(h) R[u] = dtime++;
}
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() - 1) {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:33:26: 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 < c.size(); ++i){
      |                        ~~^~~~~~~~~~
stations.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             if(i == c.size() - 1) {if(c[i] <= t && t < s) return i; continue;}
      |                ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 618 ms 1036 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 490 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 610 ms 992 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 916 ms 864 KB Output is correct
2 Correct 771 ms 952 KB Output is correct
3 Incorrect 713 ms 948 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 717 ms 992 KB Wrong query response.
2 Halted 0 ms 0 KB -