Submission #1065920

# Submission time Handle Problem Language Result Execution time Memory
1065920 2024-08-19T13:07:47 Z Ahmed57 Stations (IOI20_stations) C++17
0 / 100
607 ms 912 KB
#include "bits/stdc++.h"
using namespace std;
int dep[1001];
int timer = 0;
vector<int> adj[1001];
int in[1001],out[1001];
void dfs(int i,int pr){
    dep[i] = dep[pr]+1;
    if(dep[i]%2){
        timer++;
    }
    in[i] = timer;
    for(auto j:adj[i]){
        if(j==pr)continue;
        dfs(j,i);
    }
    if(dep[i]%2==0)timer++;
    out[i] = timer;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
    timer = 0;
    for(int i = 0;i<n;i++){
        adj[i].clear();
    }
    for(int i = 0;i<n-1;i++){
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    dep[0] = 1;
    dfs(0,0);
    vector<int> lol;
    for(int i = 0;i<n;i++){
        if(dep[i]%2==0){
            lol.push_back(in[i]);
            //cout<<in[i]<<" ";
        }else{
            lol.push_back(out[i]);
            //cout<<out[i]<<" ";
        }
    }
    return lol;
}

int find_next_station(int s, int t, vector<int> c){
    sort(c.begin(),c.end());
    if(c.size()==1)return c[0];
    if(c[0]<s){
        vector<int> na;
        for(int i = 1;i<c.size();i++)na.push_back(i);
        na.push_back(s);
        if(t<c[1]||t>s)return c[0];
        int lol = 0;
        for(int i = 0;i<na.size();i++){
            if(t>=na[i]){
                lol = na[i];
            }
        }
        return lol;
    }else{
        vector<int> na;
        na.push_back(s);
        for(int i = 0;i<c.size()-1;i++)na.push_back(i);
        if(t>c[c.size()-2]||t<s)return c.back();
        int lol = 0;
        for(int i = 0;i<na.size();i++){
            if(t<=na[i]){
                lol = na[i];
                break;
            }
        }
        return lol;
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(int i = 1;i<c.size();i++)na.push_back(i);
      |                       ~^~~~~~~~~
stations.cpp:53:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int i = 0;i<na.size();i++){
      |                       ~^~~~~~~~~~
stations.cpp:62:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int i = 0;i<c.size()-1;i++)na.push_back(i);
      |                       ~^~~~~~~~~~~
stations.cpp:65:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int i = 0;i<na.size();i++){
      |                       ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 332 ms 912 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 300 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 351 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 607 ms 688 KB Output is correct
2 Incorrect 410 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 361 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -