답안 #419150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419150 2021-06-06T13:36:58 Z NintsiChkhaidze 기지국 (IOI20_stations) C++14
0 / 100
871 ms 528 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector <int> vec[1005];
int cnt,in[1005],out[1005],O[2005];
bool q=0;
void dfs(int x,int p){
    in[x] = ++cnt;
    for (int j=0;j<vec[x].size();j++){
        int to = vec[x][j];
        if (to == p) continue;
        dfs(to,x);
    }
    out[x] = cnt;
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    q=0;
    if (k <= 1000000){
        q=1;
        vector<int> labels;
        for (int i=0;i<n;i++)
            labels.pb(i);
        return labels;
    }
    vector<int> labels;
    for (int i=0;i<1001;i++){
        O[i] = 0;
        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;
    dfs(0,0);
    for (int i=0;i<n;i++)
        labels.pb(in[i]),O[in[i]] = out[i];
    
    return labels;
}
int find_next_station(int s, int t, vector<int> c) {
    if (q){
        if (c[0] == t) return t;
        if (c.size() > 1 && c[1] == t) return t;
    }
    int Ins = s,Int = t,Out = O[t];
    if (Ins < Int){
        for (int i=1;i<c.size();i++)
            if (Int >= c[i] && O[c[i]] >= Out) return c[i];
    }
    return c[0];
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     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:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i=0;i<u.size();i++){
      |                  ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for (int i=1;i<c.size();i++)
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 602 ms 520 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 487 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 615 ms 508 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 871 ms 512 KB Output is correct
2 Correct 827 ms 528 KB Output is correct
3 Incorrect 733 ms 528 KB Wrong query response.
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 610 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -