답안 #233520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233520 2020-05-20T19:47:41 Z crossing0ver 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long 
#define fi first
#define se second
#include "crocodile.h"
using namespace std;
vector <pair<int,int > > adj[100000];
ll IN[100000][2];
bool vis[100000];
int Ein[100000],v,x;
ll dis[100000],d;
ll val;
struct cmp{
	bool operator() (int a,   int b)  {
		if (Ein[a] == Ein[b] && dis[a] == dis[b]) return a < b;
		if (Ein[a] >= 2 && Ein[b] >= 2)
			return dis[a] < dis[b];
			return Ein[a] >= 2;
	}
};
 
long long travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for (int i = 0; i < M; i++) {
		adj[ R[i][0] ].push_back( { L [i], R[i][1] } );
		adj[ R[i][1] ].push_back( { L[i] , R[i][0] });
	}
	for (int i = 0; i <  100000; i++)
		dis[i] = 100000000000000; 
	set<int,cmp>  s;
	for (int i = 0; i < K; i++) 
		Ein[P[i]] = 2,dis[P[i]] = 0,s.insert (P[i]);
	while (!s.empty()) {
		 v = *s.begin();
		if (Ein[v] < 2) break;       
		s.erase(s.begin());
		if (vis[v]) continue;
		vis[v] = 1;
		for (auto i : adj[v]) {
			 x = i.se;
			if (vis[x]) continue;
			s.erase(x);
		   d = i.fi + dis[v];
		   if (IN[x][0] == 0) IN[x][0] = d;
		   else if (IN[x][1] == 0) {
		   	IN[x][1] = d;
		   	if (IN[x][0] > IN[x][1]) swap(IN[x][0],IN[x][1]);
		   }
		   else if (IN[x][1] > d) {
		   	IN[x][1] = d;
		   	if (IN[x][0] > IN[x][1]) swap(IN[x][0],IN[x][1]);
		   }
			Ein[x] ++;
			if (IN[x][1] && dis[x] > IN[x][1]) {
					dis[x] = IN[x][1];
			}
			s.insert (x);
		}
	}
	return dis[0];	
}        /*
main()  {
	
}             */

Compilation message

crocodile.cpp: In member function 'bool cmp::operator()(int, int)':
crocodile.cpp:16:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if (Ein[a] >= 2 && Ein[b] >= 2)
   ^~
crocodile.cpp:18:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    return Ein[a] >= 2;
    ^~~~~~
crocodile.cpp: In function 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:22:11: error: ambiguating new declaration of 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)'
 long long travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
           ^~~~~~~~~~~
In file included from crocodile.cpp:5:0:
crocodile.h:1:5: note: old declaration 'int travel_plan(int, int, int (*)[2], int*, int, int*)'
 int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]);
     ^~~~~~~~~~~