제출 #780950

#제출 시각아이디문제언어결과실행 시간메모리
780950kamelfanger83기지국 (IOI20_stations)C++14
8 / 100
708 ms588 KiB
#include "stations.h"
#include <vector>
#include <numeric>

using namespace std;

vector<pair<int, int>> prepost;
vector<vector<int>> cons;
int C = 0;

void dfs(int i, int from){
    prepost[i].first = C++;
    for (int c : cons[i]){
        if (c == from) continue;
        dfs(c, i);
    }
    prepost[i].second = C;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels(n);
    iota(labels.begin(), labels.end(), 1);
    return labels;
    cons.clear();
    cons.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        cons[u[i]].push_back(v[i]);
        cons[v[i]].push_back(u[i]);
    }



    prepost.resize(n);
    C = 0;
    dfs(0, -1);

    for (int i = 0; i < n; ++i) {
        labels[i] = prepost[i].first * 1000 + prepost[i].second;
    }

    return labels;
}

int log2(int n){
    int res = 0, t = 1;
    while(t <= n){
        t <<=1;
        res++;
    }
    return res - 1;
}

int find_next_station(int s, int t, vector<int> c) {

    bool isdes = t > s && (t >> log2(t) - log2(s)) == s;
    if (!isdes) return s/2;
    else return t >> log2(t) - log2(s) - 1;

    /*
    int spre = s / 1000, spost = s % 1000;
    int tpre = t / 1000, tpost = t % 1000;
    bool isdes = spre < tpre && tpost <= spost;
    for (int i = 0; i < c.size(); ++i) {
        int cpre = c[i] / 1000, cpost = c[i] % 1000;
        bool isanc = cpre < spre && spost <= cpost;
        if (!isdes) {
            if (isanc) return c[i];
        }
        if (isdes){
            if (!isanc && cpre <= tpre && tpost <= cpost) return c[i];
        }
    }
    //return 0;*/
}

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:55:41: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   55 |     bool isdes = t > s && (t >> log2(t) - log2(s)) == s;
      |                                 ~~~~~~~~^~~~~~~~~
stations.cpp:57:40: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   57 |     else return t >> log2(t) - log2(s) - 1;
      |                      ~~~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...