답안 #420316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420316 2021-06-08T09:39:03 Z NintsiChkhaidze 기지국 (IOI20_stations) C++14
0 / 100
1190 ms 640 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector <int> vec[1005],labels;
int cnt = 0,in[1005],out[1005];
void dfs(int x,int p,int t){
    in[x] = cnt++;
    if (t%2) labels[x] = in[x];
    
    for (int j=0;j<vec[x].size();j++){
        int to = vec[x][j];
        if (to == p) continue;
        dfs(to,x,t + 1);
    }
    out[x] = cnt++;
    if (!labels[x]) labels[x] = out[x];
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    for (int i=0;i<1001;i++){
        vec[i].clear();
        in[i] = out[i] = 0;
    }
    for (int i=0;i<u.size();i++){
        vec[u[i]].pb(v[i]);
        vec[v[i]].pb(u[i]);
    }
    
    cnt=0;
    labels.clear();
    for (int i=0;i<n;i++)
        labels.pb(0);
    dfs(0,0,0);
    return labels;
}
int find_next_station(int s, int t, vector<int> c) {
    sort(c.begin(),c.end());
    if (s > c[0]){
        //s - out
        for (int i = 1; i<c.size();i++){
            int l = c[i],r = s - 1;
            if (i!=c.size() - 1) r = c[i + 1] - 1;
            
            if (l <= t && t <= r) return c[i];
        }
        return c[0];
    }
    else{
        //s - in
        for (int i = 1; i<c.size(); i++){
            int l = s + 1,r = c[i];
            if (i > 1) l = c[i - 1] + 1;
            
            if (l <= t && t <= r) return c[i];
        }
        return c[0];
    }
}

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int j=0;j<vec[x].size();j++){
      |                  ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i=0;i<u.size();i++){
      |                  ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (int i = 1; i<c.size();i++){
      |                         ~^~~~~~~~~
stations.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             if (i!=c.size() - 1) r = c[i + 1] - 1;
      |                 ~^~~~~~~~~~~~~~
stations.cpp:51:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for (int i = 1; i<c.size(); i++){
      |                         ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 440 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=0, label=1995
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 320 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1991
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 615 ms 628 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1190 ms 456 KB Output is correct
2 Incorrect 837 ms 516 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 611 ms 640 KB Wrong query response.
2 Halted 0 ms 0 KB -