답안 #114355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114355 2019-06-01T04:58:51 Z faustaadp Shortcut (IOI16_shortcut) C++17
0 / 100
2 ms 384 KB
#include "shortcut.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,jar[550],tam[550],has,j,d[550],C;
vector<ll> v[550],w[550];
ll cek(ll aa,ll bb)
{
	ll ii;
	for(ii=0;ii<(n*2);ii++)
	{
		v[ii].clear();
		w[ii].clear();
	}
	for(ii=0;ii<(n-1);ii++)
	{
		v[ii].pb(ii+1);
		w[ii].pb(jar[ii]);
		v[ii+1].pb(ii);
		w[ii+1].pb(jar[ii]);
	}
	for(ii=0;ii<n;ii++)
	{
		v[ii].pb(ii+n);
		w[ii].pb(tam[ii]);
		v[ii+n].pb(ii);
		w[ii+n].pb(tam[ii]);
	}
	v[aa].pb(bb);
	w[aa].pb(C);
	v[bb].pb(aa);
	w[bb].pb(C);
	priority_queue<pair<ll,ll> > pq;
	ll ma=0,cln=0;
	for(ii=0;ii<(n*2);ii++)
		d[ii]=1e18;
	d[0]=0;
	pq.push(mp(0,0));
	while(!pq.empty())
	{
		ll u=pq.top().se;
		ll dis=-pq.top().fi;
		pq.pop();
		if(d[u]!=dis)
			continue;
		//cout<<aa<<" "<<bb<<" "<<u<<" "<<dis<<" "<<d[u]<<"\n";
		ma=max(ma,d[u]);
		if(ma==d[u])
			cln=u;
		ll ii;
		for(ii=0;ii<v[u].size();ii++)
		{
			if(d[v[u][ii]]>d[u]+w[u][ii])
			{
				d[v[u][ii]]=d[u]+w[u][ii];
				pq.push(mp(-d[v[u][ii]],v[u][ii]));
			}
		}
	}
	//cout<<ma<<" "<<cln<<"\n";
	ma=0;
	for(ii=0;ii<(n*2);ii++)
		d[ii]=1e18;
	d[cln]=0;
	pq.push(mp(0,cln));
	cln=0;
	while(!pq.empty())
	{
		ll u=pq.top().se;
		ll dis=-pq.top().fi;
		pq.pop();
		if(d[u]!=dis)
			continue;
		ma=max(ma,d[u]);
		if(ma==d[u])
			cln=u;
		ll ii;
		for(ii=0;ii<v[u].size();ii++)
		{
			if(d[v[u][ii]]>d[u]+w[u][ii])
			{
				d[v[u][ii]]=d[u]+w[u][ii];
				pq.push(mp(-d[v[u][ii]],v[u][ii]));
			}
		}
	}
	//cout<<ma<<"\n";
	return ma;
}
long long find_shortcut(int N, std::vector<int> l, std::vector<int> d, int c)
{
	n=N;
	C=c;
	for(i=0;i<(n-1);i++)
		jar[i]=l[i];
	for(i=0;i<n;i++)
		tam[i]=d[i];
	has=1e18;
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			has=min(has,cek(i,j));
    return has;
}

Compilation message

shortcut.cpp: In function 'll cek(ll, ll)':
shortcut.cpp:55:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<v[u].size();ii++)
            ~~^~~~~~~~~~~~
shortcut.cpp:82:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<v[u].size();ii++)
            ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 384 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -