Submission #29057

# Submission time Handle Problem Language Result Execution time Memory
29057 2017-07-18T07:52:23 Z dereotu Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
363 ms 262144 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
#define exit adsjdsa
using namespace std;
//kaçışlar leaf
//her node için en büyük ikiyi tut 
//vector < ii > adj[1005];
int exit[1005];
int adj[1005][1005];
//vector <int> nodes[1005];
int nodes[1005];
void dfs(int x,int y){
	if(exit[x]){
		nodes[x]=0;
		return;
	}
	forr(i,0,1005){
		if(adj[x][i]!=0 and i!=y){
			dfs(i,x);
		}
	}
	int best=1e9,secondbest=1e9;
	forr(i,0,1005){
		if(adj[x][i]!=0 and i!=y){
			if(adj[x][i]+nodes[i]<best){
				secondbest=best;
				best=adj[x][i]+nodes[i];
			}
			else if(adj[x][i]+nodes[i]<secondbest){
				secondbest=adj[x][i]+nodes[i];
			}
		}
	}
	nodes[x]=(secondbest==1e9?best:secondbest);
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	forr(i,0,M){
		//adj[R[i][0]].pb(mp(L[i],R[i][1]));
		//adj[R[i][1]].pb(mp(L[i],R[i][0]));
		adj[R[i][0]][R[i][1]]=L[i];
		adj[R[i][1]][R[i][0]]=L[i];
	}
	forr(i,0,K){
		exit[P[i]]=1;
	}
	dfs(0,-1);
	/*forr(j,0,N){
		cout<<"node "<<j<<endl;
		forr(i,0,nodes[j].size()){
			cout<<nodes[j][i]<<endl;
		}
	}*/
	//sort(nodes[0].begin(),nodes[0].end(),greater<int>());
	int ans=nodes[0];
	return ans;
}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 123356 KB Output is correct
2 Correct 0 ms 123356 KB Output is correct
3 Correct 0 ms 123356 KB Output is correct
4 Correct 0 ms 123356 KB Output is correct
5 Correct 0 ms 123356 KB Output is correct
6 Correct 0 ms 123356 KB Output is correct
7 Correct 0 ms 123356 KB Output is correct
8 Correct 0 ms 123356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 53 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 363 ms 123356 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -