Submission #72604

# Submission time Handle Problem Language Result Execution time Memory
72604 2018-08-26T11:18:08 Z MrTEK Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
11 ms 7244 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left isc+isc
#define right isc+isc+1
#define mid (l+r)/2
#define FAfi_IO ios_base::sync_with_fidio(false);
#define escl '\n'
#define bit __builtin_popcount

typedef long long int ll;

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 2e5 + 5;
const int M = 1e6 + 5;
const int SQ = 350;
const int MOD = 998244353;

typedef long long int lli;
typedef pair<int,int> pii;

struct node {
	int x,cost;
};

bool operator < (node a,node b) {
	return a.cost > b.cost;
}

priority_queue <node> Q;

vector <pii> ed[N];

int mn2[N],mn[N],ans[N];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for (int i = 0 ; i < M ; i++) {
		ed[R[i][0]].pb(mp(R[i][1],L[i]));
		ed[R[i][1]].pb(mp(R[i][0],L[i]));
	}
	memset(mn,63,sizeof mn);
	memset(mn2,63,sizeof mn2);
	for (int i = 0 ; i < K ; i++) {
		if (P[i] == 0) return 0;
		Q.push({P[i],0});
	}
	while(len(Q)) {
		auto it = Q.top();
		Q.pop();
		if (it.cost > mn2[it.x]) continue;
		for (auto i : ed[it.x]) {
			int u = i.fi;
			int v = i.sc;
			int tut = mn2[u];
			mn2[u] = min(mn2[u],v + it.cost);
			if (mn2[u] < mn[u]) swap(mn2[u],mn[u]);
			if (mn2[u] != tut)
				Q.push({u,mn2[u]});
		}
	}
	return mn2[0];
}


# Verdict Execution time Memory Grader output
1 Correct 6 ms 6648 KB Output is correct
2 Correct 6 ms 6648 KB Output is correct
3 Correct 8 ms 6836 KB Output is correct
4 Correct 8 ms 6836 KB Output is correct
5 Correct 9 ms 6836 KB Output is correct
6 Correct 9 ms 6920 KB Output is correct
7 Correct 9 ms 6920 KB Output is correct
8 Correct 9 ms 6920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6648 KB Output is correct
2 Correct 6 ms 6648 KB Output is correct
3 Correct 8 ms 6836 KB Output is correct
4 Correct 8 ms 6836 KB Output is correct
5 Correct 9 ms 6836 KB Output is correct
6 Correct 9 ms 6920 KB Output is correct
7 Correct 9 ms 6920 KB Output is correct
8 Correct 9 ms 6920 KB Output is correct
9 Correct 10 ms 6988 KB Output is correct
10 Correct 8 ms 6988 KB Output is correct
11 Correct 10 ms 6988 KB Output is correct
12 Correct 11 ms 7116 KB Output is correct
13 Correct 10 ms 7244 KB Output is correct
14 Incorrect 9 ms 7244 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6648 KB Output is correct
2 Correct 6 ms 6648 KB Output is correct
3 Correct 8 ms 6836 KB Output is correct
4 Correct 8 ms 6836 KB Output is correct
5 Correct 9 ms 6836 KB Output is correct
6 Correct 9 ms 6920 KB Output is correct
7 Correct 9 ms 6920 KB Output is correct
8 Correct 9 ms 6920 KB Output is correct
9 Correct 10 ms 6988 KB Output is correct
10 Correct 8 ms 6988 KB Output is correct
11 Correct 10 ms 6988 KB Output is correct
12 Correct 11 ms 7116 KB Output is correct
13 Correct 10 ms 7244 KB Output is correct
14 Incorrect 9 ms 7244 KB Output isn't correct
15 Halted 0 ms 0 KB -