답안 #751017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
751017 2023-05-30T19:32:11 Z Rejep 사이버랜드 (APIO23_cyberland) C++17
컴파일 오류
0 ms 0 KB
#include "cyberland.h"



#include<bits/stdc++.h>

#define db double

#define pb push_back

#define ft first

#define sd second

using namespace std;

const db INF=1e18+1;

vector<vector<pair<int,db>>>g(1e5);

vector<bool>vis(1e5,0), ar(1e5,0);

vector<int>arr(1e5);

int n, m, k, h;



void dfs(int x){

	vis[x]=1;

	if (x==h)return;

	if (arr[x]==0)ar[x]=1;

	for (auto u:g[x]){

		if (!vis[u.ft]){

			dfs(u.ft);

		}

	}

}



db pw(db x, ll y){

	if (!y)return 1;

	if (y % 2)return pw(x, y-1)*x;

	db tmp=pw(x, y/2);

	return tmp*tmp;

}



double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> C, vector<int> ARR) {

	n=N;m=M;k=K;H=h;arr=ARR;

	for (int i=0; i<m; i++){

		g[x[i]].pb({y[i],c[i]});

		g[y[i]].pb({x[i],c[i]});

	}

	arr[0]=0;

	

	dfs(0);

	

	vector<int> ls (n, -1);

	ls[h] = 0;

	vector<bool> u1 (n, 0);

	for (int i=0; i<n; ++i) {

		int v = -1;

		for (int j=1; j<n; ++j)

			if (!u1[j] && (v == -1 || ls[j] > ls[v]))

				v = j;

		if (v==-1||ls[v]==-1)

			break;

		u1[v] = 1;

 

		for (int j=0; j<(int)g[v].size(); ++j) {

			int to = g[v][j].ft;

			if (u1[to])continue;

			if (arr[to]==2){

				ls[to]=max(ls[v]+1,ls[to]);

			}else ls[to]=max(ls[v],ls[to]);

			

		}

	}

	

	vector<db> d (n, INF);

	d[h] = 0;

	vector<bool> u (n, 0);

	for (int i=0; i<n; ++i) {

		int v = -1;

		for (int j=0; j<n; ++j)

			if (!u[j] && (v == -1 || d[j] < d[v]))

				v = j;

		if (d[v] == INF)

			break;

		u[v] = 1;

 

		for (int j=0; j<(int)g[v].size(); ++j) {

			int to = g[v][j].ft;

			db len = g[v][j].sd;

			db k2=pw(2.0,min(ls[v],k));

			if (d[v] + (len / k2) < d[to]) {

				d[to] = d[v] + len/k2;

			}

		}

	}

	

	db ans = INF;

	for (int i=0; i<n; i++){

		if (ar[i])ans=min(ans,d[i]);

	}

	

	if (ans==INF)return -1;

	else return ans;

}

Compilation message

cyberland.cpp:52:13: error: 'll' has not been declared
   52 | db pw(db x, ll y){
      |             ^~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:72:20: error: 'c' was not declared in this scope
   72 |   g[x[i]].pb({y[i],c[i]});
      |                    ^
cyberland.cpp:72:25: error: no matching function for call to 'std::vector<std::pair<int, double> >::push_back(<brace-enclosed initializer list>)'
   72 |   g[x[i]].pb({y[i],c[i]});
      |                         ^
In file included from /usr/include/c++/10/vector:67,
                 from cyberland.h:1,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, double>; _Alloc = std::allocator<std::pair<int, double> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, double>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, double>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, double>; _Alloc = std::allocator<std::pair<int, double> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, double>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, double> >::value_type&&' {aka 'std::pair<int, double>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
cyberland.cpp:74:25: error: no matching function for call to 'std::vector<std::pair<int, double> >::push_back(<brace-enclosed initializer list>)'
   74 |   g[y[i]].pb({x[i],c[i]});
      |                         ^
In file included from /usr/include/c++/10/vector:67,
                 from cyberland.h:1,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, double>; _Alloc = std::allocator<std::pair<int, double> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, double>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, double>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, double>; _Alloc = std::allocator<std::pair<int, double> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, double>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, double> >::value_type&&' {aka 'std::pair<int, double>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~