제출 #547556

#제출 시각아이디문제언어결과실행 시간메모리
547556tmn2005Commuter Pass (JOI18_commuter_pass)C++17
컴파일 에러
0 ms0 KiB
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

#define fr first
#define sc second

#define mk make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front

#define int long long
#define pii pair<int,int>
#define piii pair<int,pii>

#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()

#define NeedForSpeed ios::sync_with_stdio(0), cin.tie(0)
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
const int N = 1e5 + 12, INF = 1e18;
int n, m, k, a, b, c, d, s, f, l, r, x, y, z, res = INF, dis[505][505];
//vector<pii> g[N];
//vector<int> ds(N, INF), df(N, INF), dl(N, INF), dr(N, INF);

void solve(){
	cin>>n>>m;
	cin>>s>>f;
	cin>>l>>r;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			if(i == j)
				dp[i][j] = 0;
			else
				dp[i][j] = INF;
		}
	}
	for(int i=1; i<=m; i++){
		cin>>x>>y>>z;
		dis[x][y] = z;
		dis[y][x] = z;
	}
	for(int i=1; i<=n; i++)dis[i][i] = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			for(int k=1; k<=n; k++){
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	res = dis[l][r];
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			if(dis[s][i] + dis[i][j] + dis[j][f] == dis[s][f]){
				res = min(res, dis[l][i] + dis[j][r]);
				res = min(res, dis[r][i] + dis[j][l]);
			}
		}	
	}
	cout<<res<<"\n";
}
main(){
	NeedForSpeed;
	int T = 1;
//	cin >> T;
	while(T--){
		solve();
	}
	return 0;
}

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

commuter_pass.cpp: In function 'void solve()':
commuter_pass.cpp:39:5: error: 'dp' was not declared in this scope; did you mean 'd'?
   39 |     dp[i][j] = 0;
      |     ^~
      |     d
commuter_pass.cpp:41:5: error: 'dp' was not declared in this scope; did you mean 'd'?
   41 |     dp[i][j] = INF;
      |     ^~
      |     d
commuter_pass.cpp: At global scope:
commuter_pass.cpp:68:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   68 | main(){
      | ^~~~