Submission #460656

# Submission time Handle Problem Language Result Execution time Memory
460656 2021-08-09T08:16:42 Z Khizri Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
2000 ms 2380 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back		 
#define F first																 
#define S second 															 
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
const int mxn=1000+5;
ll isexit[mxn],col[mxn],n,m,arr[mxn];
vector<pll>vt[mxn];
ll funk(int u,ll sum,vector<int>color){
	if(isexit[u]){
		return sum;
	}
	vector<int>v;
	color[u]=1;
	for(int i=0;i<vt[u].size();i++){
		if(!color[vt[u][i].F]){
			int q=funk(vt[u][i].F,sum+vt[u][i].S,color);
			if(v.size()<2){
				v.pb(q);
				sort(all(v));
			}
			else{
				if(q<v.back()){
					v.pop_back();
					v.pb(q);
					sort(all(v));
				}
			}
		}
	}
	return v[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	n=N,m=M;
	for(int i=0;i<m;i++){
		vt[R[i][0]].pb({R[i][1],L[i]});
		vt[R[i][1]].pb({R[i][0],L[i]});
	}
	for(int i=0;i<K;i++){
		isexit[P[i]]=1;
	}
	vector<int>vv;
	for(int i=0;i<=n;i++){
		vv.pb(0);
		arr[i]=INF;
	}
	ll ans=funk(0,0,vv);
	return ans;
}

Compilation message

crocodile.cpp: In function 'long long int funk(int, long long int, std::vector<int>)':
crocodile.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i=0;i<vt[u].size();i++){
      |              ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 972 KB Output is correct
7 Correct 3 ms 1996 KB Output is correct
8 Correct 2 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 972 KB Output is correct
7 Correct 3 ms 1996 KB Output is correct
8 Correct 2 ms 2380 KB Output is correct
9 Execution timed out 2087 ms 844 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 972 KB Output is correct
7 Correct 3 ms 1996 KB Output is correct
8 Correct 2 ms 2380 KB Output is correct
9 Execution timed out 2087 ms 844 KB Time limit exceeded
10 Halted 0 ms 0 KB -