제출 #719272

#제출 시각아이디문제언어결과실행 시간메모리
719272ChrisM2309Race (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define F first
#define S second
#define int long long 
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define F first
#define S second
 
int best_path(int n, int k, int h[][2], int L[]){
  vector<pair<int,int>> roads;
  vector<int> w;
  for (int i = 0; i < n - 1; i++){
    ///cout << L[i] << " " << h[i][0] << " " << h[i][1] << "\n";
    if (L[i] == k) return 1;
    //if(L[i] > k) continue;
    roads.push_back({h[i][0], h[i][1]});
    w.push_back(L[i]);
  }
  vector<vii> graph(n);
  for (int i = 0; i < roads.size(); i++){
      int u = roads[i].F, v = roads[i].S;
      graph[u].push_back({v,w[i]});
      graph[v].push_back({u,w[i]});
  }
  int ans = INT_MAX;
  vector<bool> temp(n,0);
  vector<vector<bool>> vis(n, temp);
   for (int s = 0; s < n; s++){
      // Definir que punto iniciara el algoritmo
      // Guaradar info como v,w
      vector<int> peso(n,INT_MAX);
      vector<int> dist(n, 0);
      // Aqui dist[s], s es el inicio
      peso[s] = 0;
      vis[s][s] = 1;
      priority_queue<ii,vii,greater<ii>> pq;
      pq.push(ii(0,s));
      while(!pq.empty()){
          int d = pq.top().F;
          int u = pq.top().S;
          pq.pop();
          if (d > peso[u]) continue;
          for (auto  x : graph[u]){
              if(vis[x.F][u]) continue;
              if(peso[u] + x.S < peso[x.F]){
                  peso[x.F] = peso[u] + x.S;
                  dist[x.F] = dist[u] + 1;
                  // Se invierte de v,w a w,v
                  pq.push(ii(peso[x.F],x.F));
                  vis[u][x.F] = 1;
              } 
          }
      }
      auto f = find(peso.begin(), peso.end(), k);
      if (f != peso.end()){
         int p = f - peso.begin();
         ans = min(ans, dist[p]);
      }
      //cout << s << " : ";
      //for (int i = 0; i < n; i++) cout << peso[i] << "," << dist[i] << " ";
      cout << "\n";
  }
  if (ans == INT_MAX) return -1;
  return ans;
}

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

race.cpp:12:23: error: conflicting declaration 'typedef struct std::pair<long long int, long long int> ii'
   12 | typedef pair<int,int> ii;
      |                       ^~
race.cpp:4:24: note: previous declaration as 'typedef struct std::pair<int, int> ii'
    4 | typedef pair<int, int> ii;
      |                        ^~
race.cpp: In function 'long long int best_path(long long int, long long int, long long int (*)[2], long long int*)':
race.cpp:28:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for (int i = 0; i < roads.size(); i++){
      |                   ~~^~~~~~~~~~~~~~