답안 #1080831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080831 2024-08-29T14:42:12 Z The_Blitz 기지국 (IOI20_stations) C++17
0 / 100
601 ms 940 KB
// TODO -> PONER ALGO AQUI
// amigos y no mas
// I'm in the coolest driver high
// += O(logn) ; + = O(n)
 
#include <bits/stdc++.h>
#include "stations.h"
#include <variant>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define ones(x) __builtin_popcount(x)
#define loga2(x) __builtin_ctzll(x)
#define pos2(x) __builtin_clzll(x)

using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair <ii, ii> iiii;
typedef vector <int> vi;
typedef vector <ii> vii;

const int mod = 998244353;
const ll inf = (1LL<<62)-1;

struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

vector< vector<int> > G;
vector<int> order;
vector<bool> vis;
int N;
int cont = 0;

void dfs(int x){
  order[x] = cont; cont++;
  for(int i=0; i<G[x].size(); i++){
    int &y = G[x][i];
    if(!vis[y]){
      vis[y] = true;
      dfs(y);
    }
  }
  
}


vector<int> label(int n, int k, vector<int> u, vector<int> v) {
  N = n;
  vector<int> labels(n);

  G.clear(); 
  order.clear(); 
  vis.clear();

  G.resize(n);
  order.resize(n);
  vis.resize(n,0);

  for(int i=0; i<n-1;i++){
    G[u[i]].push_back(v[i]);
    G[v[i]].push_back(u[i]);
  }

  vis[0] = true;
  dfs(0);

  for (int i = 0; i < n; i++) {
    labels[i] = order[i];
  }

  return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
  auto it = *upper_bound(c.begin() , c.end() , s);
  return it;
}

Compilation message

stations.cpp: In function 'void dfs(int)':
stations.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i=0; i<G[x].size(); i++){
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 344 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=69, label=1001
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 344 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=2, label=1508
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 361 ms 940 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 601 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 335 ms 940 KB Wrong query response.
2 Halted 0 ms 0 KB -