Submission #1106458

# Submission time Handle Problem Language Result Execution time Memory
1106458 2024-10-30T11:35:56 Z snpmrnhlol Stations (IOI20_stations) C++17
0 / 100
768 ms 668 KB
#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    vector <vector<int>> e;
    vector<int> labels;
    e.resize(n);
    int cnt = 0;
    auto dfs = [&](auto self, int node, int p, int d) -> void{
        if(d == 0)labels[node] = cnt++;
        for(auto i:e[node]){
            if(i == p)continue;
            self(self, i, node, d^1);
        }
        if(d == 1)labels[node] = cnt++;
    };
	labels.resize(n);
	for(int i = 0;i < n - 1;i++){
        e[u[i]].push_back(v[i]);
        e[v[i]].push_back(u[i]);
	}
	for(int i = 0;i < n;i++){
        if(e[i].size() == 1){
            dfs(dfs, i, -1, 0);
            break;
        }
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    int stl = 1000000,str = -1;
    if(s < c[0]){
        ///bot
        stl = s;
        for(auto i:c){
            str = max(str,i);
        }
        if(stl <= t && t <= str){
            return str;
        }else{
            int nr = 1000000;
            for(auto i:c){
                if(t <= i){
                    nr = min(nr, i);
                }
            }
            return nr;
        }
    }else{
        str = s;
        for(auto i:c){
            stl = min(stl,i);
        }
        if(stl <= t && t <= str){
            return stl;
        }else{
            int nr = -1;
            for(auto i:c){
                if(i <= t){
                    nr = max(nr, i);
                }
            }
            return nr;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 488 ms 668 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 417 ms 668 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 458 ms 668 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 768 ms 668 KB Output is correct
2 Incorrect 587 ms 668 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 474 ms 668 KB Wrong query response.
2 Halted 0 ms 0 KB -