답안 #1088338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088338 2024-09-14T09:16:32 Z Rolo678 Aesthetic (NOI20_aesthetic) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<pair<int,int>>>g(3e5+5);
vector<long long>dp2(3e5+5,-1);
 vector<long long>dp(3e5+5,-1);
 
signed main()
{
  int n,m;
  cin >> n>>m;
 // cin >> n >> m;
  vector<pair<int,int>>e;
  for(int i = 1;i<=m;i++)
  {
    int a,b,w;
    cin >> a >> b >> w;
    //cout << 'o';
    g[a].push_back({b,i});
    g[b].push_back({a,i});
    e[i] = {a,b};
//cout << 'o';
  }
 
  for(int i = n-1;i> 0;i--)
  {
   
  }
 
  //dfs();
  dp[1] =0;
  queue<int>q;
  q.push_back(1);
  while(!q.empty())
  {
    v = q.top();
    q.pop();
    for(auto i : g[v])
    {
      if(dp[u] == -1)
      {
        q.push(u);
        dp[u] = dp[v] + 1;
      }
    }
  }
    dp2[n] =0;
  queue<int>q;
  q.push_back(n);
  while(!q.empty())
  {
    int v = q.front();
    q.pop();
    for(auto i : g[v])
    {
      if(dp2[u] == -1)
      {
        q.push(u);
        dp2[u] = dp2[v] + 1;
      }
    }
  }
  int mn = 1e9+5;
  int num = 0;
  for(auto i : e)
  {
    if(dp[i.first] + dp2[i.second]+1 == mn)
    {
      num++;
    }
    else if(dp[i.first] + dp2[i.second+1 <mn)
    {
       int mn = dp[i.first] + dp2[i.second] +1 ;
     num = 1;
    }
  }
   cout << mn + (num > 1);
}

Compilation message

Aesthetic.cpp: In function 'int main()':
Aesthetic.cpp:33:5: error: 'class std::queue<long long int>' has no member named 'push_back'
   33 |   q.push_back(1);
      |     ^~~~~~~~~
Aesthetic.cpp:36:5: error: 'v' was not declared in this scope
   36 |     v = q.top();
      |     ^
Aesthetic.cpp:36:11: error: 'class std::queue<long long int>' has no member named 'top'; did you mean 'pop'?
   36 |     v = q.top();
      |           ^~~
      |           pop
Aesthetic.cpp:40:13: error: 'u' was not declared in this scope
   40 |       if(dp[u] == -1)
      |             ^
Aesthetic.cpp:48:13: error: redeclaration of 'std::queue<long long int> q'
   48 |   queue<int>q;
      |             ^
Aesthetic.cpp:32:13: note: 'std::queue<long long int> q' previously declared here
   32 |   queue<int>q;
      |             ^
Aesthetic.cpp:49:5: error: 'class std::queue<long long int>' has no member named 'push_back'
   49 |   q.push_back(n);
      |     ^~~~~~~~~
Aesthetic.cpp:56:14: error: 'u' was not declared in this scope
   56 |       if(dp2[u] == -1)
      |              ^
Aesthetic.cpp:71:45: error: expected ']' before ')' token
   71 |     else if(dp[i.first] + dp2[i.second+1 <mn)
      |                                             ^
      |                                             ]
Aesthetic.cpp:73:12: warning: unused variable 'mn' [-Wunused-variable]
   73 |        int mn = dp[i.first] + dp2[i.second] +1 ;
      |            ^~