답안 #1090618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090618 2024-09-18T14:16:01 Z onlk97 기지국 (IOI20_stations) C++14
0 / 100
605 ms 936 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

vector <int> g[1010];
int in[1010],out[1010],dep[1010],tme;
void dfs(int cur,int prv){
    if (prv==-1) dep[cur]=0;
    else dep[cur]=dep[prv]+1;
    in[cur]=++tme;
    for (int i:g[cur]){
        if (i==prv) continue;
        dfs(i,cur);
    }
    out[cur]=++tme;
}
vector <int> label(int n,int k,vector <int> u,vector <int> v){
    for (int i=0; i<n; i++) g[i].clear();
    tme=0;
    for (int i=0; i<n-1; i++){
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }
    dfs(0,-1);
    vector <int> ret(n);
    for (int i=0; i<n; i++){
        if (dep[i]%2==0) ret[i]=in[i];
        else ret[i]=out[i];
    }
    return ret;
}

int find_next_station(int s,int t,vector <int> c){
    if (c.size()==1) return c[0];
    if (s>*max_element(c.begin(),c.end())){
        for (int i=1; i+1<c.size(); i++){
            if (c[i]<=t&&t<c[i+1]) return c[i];
        }
        if (t<=s) return c.back();
        return c.front();
    }
    for (int i=1; i+1<c.size(); i++){
        if (c[i-1]<t&&t<=c[i]) return c[i];
    }
    if (t>=s) return c.front();
    return c.back();
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i=1; i+1<c.size(); i++){
      |                       ~~~^~~~~~~~~
stations.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i=1; i+1<c.size(); i++){
      |                   ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1991
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1023
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 372 ms 700 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 605 ms 684 KB Output is correct
2 Incorrect 458 ms 936 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 363 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -