답안 #233402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233402 2020-05-20T12:21:55 Z crossing0ver 악어의 지하 도시 (IOI11_crocodile) C++17
89 / 100
2000 ms 103648 KB
#include<bits/stdc++.h>
#define fi first
#define se second
//#include "crocodile.h"
using namespace std;
vector <pair<int,int > > adj[100000];
multiset <int> IN[100000];
bool vis[100000];
int Ein[100000],dis[100000];
struct cmp{
//pair<int,pair<int,int> > a,  b	;
	bool operator() (const  pair<int,pair<int,int> > &a,  const pair<int,pair<int,int> > &b) const {
		if (a.se.se >= 2 && b.se.se >= 2)
			return a.se.fi <= b.se.fi;
		return (a.se.se  >= 2); 
	}
};

int 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] });
	}
	fill(dis,dis + 100000,2000000);
	set<pair<int,pair<int,int> >,cmp  >  s;
	for (int i = 0; i < K; i++) 
		s.insert ({P[i] , {0,2}}), Ein[P[i]] = 2,dis[P[i]] = 0;	
	//	cout << s.size()<<'\n';
	//	exit(0);
	while (!s.empty()) {
		int v = s.begin()->first;
		int val = (s.begin()->se).fi;
		int count = (s.begin()->se).se;   // cout << v <<'\n';
		if (count < 2) break;            
		s.erase(s.begin());
		if (vis[v]) continue;
		dis[v] = val;
		vis[v] = 1;
		for (auto i : adj[v]) {
			
			int x = i.se, d = i.fi;
			if (vis[x]) continue;
			IN[x].insert(dis[v] + d);
			s.erase ( { x, { dis[x],Ein[x] }});
			Ein[x] ++;
			if (IN[x].size() >= 2) {
				auto it = IN[x].begin();
				it++;
				if (dis[x] > *it) {
					dis[x] = *it;
				}
			}
			s.insert ( { x, { dis[x],Ein[x] }});
		}
	}
	return dis[0];	
}     /*
main() {               int n,m,k;
	cin >> n >> m >> k;
	int R[m][2],L[m]; for(int i = 0; i < m ; i++ )cin >> R[i][0] >> R[i][1] >> L[i];
	  int P[k]; for (int i = 0 ; i < k ; i++) cin >> P[i];
	travel_plan(n,m,R,L,k,P);
	
}  */
/* 5 4 3
 0 1 2
 0 2 3
 3 2 1
 2 4 4
 1 3 4
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7808 KB Output is correct
2 Correct 9 ms 7808 KB Output is correct
3 Correct 10 ms 7808 KB Output is correct
4 Correct 10 ms 7936 KB Output is correct
5 Correct 10 ms 7936 KB Output is correct
6 Correct 10 ms 7936 KB Output is correct
7 Correct 10 ms 7936 KB Output is correct
8 Correct 9 ms 7936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7808 KB Output is correct
2 Correct 9 ms 7808 KB Output is correct
3 Correct 10 ms 7808 KB Output is correct
4 Correct 10 ms 7936 KB Output is correct
5 Correct 10 ms 7936 KB Output is correct
6 Correct 10 ms 7936 KB Output is correct
7 Correct 10 ms 7936 KB Output is correct
8 Correct 9 ms 7936 KB Output is correct
9 Correct 13 ms 8320 KB Output is correct
10 Correct 9 ms 7808 KB Output is correct
11 Correct 11 ms 8064 KB Output is correct
12 Correct 19 ms 8960 KB Output is correct
13 Correct 15 ms 9216 KB Output is correct
14 Correct 9 ms 7808 KB Output is correct
15 Correct 10 ms 7936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7808 KB Output is correct
2 Correct 9 ms 7808 KB Output is correct
3 Correct 10 ms 7808 KB Output is correct
4 Correct 10 ms 7936 KB Output is correct
5 Correct 10 ms 7936 KB Output is correct
6 Correct 10 ms 7936 KB Output is correct
7 Correct 10 ms 7936 KB Output is correct
8 Correct 9 ms 7936 KB Output is correct
9 Correct 13 ms 8320 KB Output is correct
10 Correct 9 ms 7808 KB Output is correct
11 Correct 11 ms 8064 KB Output is correct
12 Correct 19 ms 8960 KB Output is correct
13 Correct 15 ms 9216 KB Output is correct
14 Correct 9 ms 7808 KB Output is correct
15 Correct 10 ms 7936 KB Output is correct
16 Execution timed out 2091 ms 103648 KB Time limit exceeded
17 Halted 0 ms 0 KB -