답안 #29366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29366 2017-07-19T07:37:43 Z aybala 악어의 지하 도시 (IOI11_crocodile) C++11
100 / 100
1669 ms 199548 KB
#include<bits/stdc++.h>
#define fori(a,b,c) for(a=b; a<c; a++)
#define ford(a,b,c) for(a=b; a>=c; a--)
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define fr front
#define emp empty
#define pq priority_queue
#define pll pair<long,long>
using namespace std;

vector< pii >v[100005];
int ex[100005];
pq< pll >q;
ll dis[100005];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){	
	int i,j,k;
	fori(i,0,M){
		v[R[i][0]].pb(mp(L[i],R[i][1]));
		v[R[i][1]].pb(mp(L[i],R[i][0]));	
		//dis[i]=-1;
	}
	
	fori(i,0,K){
		ex[P[i]]=1;
		dis[P[i]]=0;	
		q.push(mp(0,P[i]));
	}
	
	while(!q.empty()){
		int t=q.top().se;
		int tfi=-q.top().fi;
		int s=v[t].size();
		q.pop();
		ex[t]++;
		if(ex[t]!=2){
			continue;
		}
		ex[t]++;
		dis[t]=tfi;
		fori(i,0,s){
			//if(ex[t]==2){
				//if((dis[v[t][i].se]>dis[t]+v[t][i].fi && ex[v[t][i].se]!=1) || (ex[v[t][i].se]==1 && dis[v[t][i].se]<dis[t]+v[t][i].fi)){
				//	dis[v[t][i].se]=dis[t]+v[t][i].fi;
					dis[t]=tfi;
					q.push(mp(-dis[t]-v[t][i].fi,v[t][i].se));
				//}
			//}
			
			
		}
	}
	return dis[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:22:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,k;
        ^
crocodile.cpp:22:10: warning: unused variable 'k' [-Wunused-variable]
  int i,j,k;
          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 122920 KB Output is correct
2 Correct 0 ms 122920 KB Output is correct
3 Correct 0 ms 122920 KB Output is correct
4 Correct 0 ms 123052 KB Output is correct
5 Correct 0 ms 123056 KB Output is correct
6 Correct 0 ms 123056 KB Output is correct
7 Correct 0 ms 123052 KB Output is correct
8 Correct 3 ms 123056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 123528 KB Output is correct
2 Correct 0 ms 122920 KB Output is correct
3 Correct 0 ms 123052 KB Output is correct
4 Correct 6 ms 123996 KB Output is correct
5 Correct 6 ms 124072 KB Output is correct
6 Correct 0 ms 122920 KB Output is correct
7 Correct 3 ms 123052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1609 ms 197188 KB Output is correct
2 Correct 126 ms 127672 KB Output is correct
3 Correct 163 ms 128860 KB Output is correct
4 Correct 1669 ms 199548 KB Output is correct
5 Correct 953 ms 195048 KB Output is correct
6 Correct 66 ms 125296 KB Output is correct
7 Correct 769 ms 142824 KB Output is correct