답안 #60761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60761 2018-07-24T16:08:27 Z KLPP Shortcut (IOI16_shortcut) C++14
0 / 100
2000 ms 24128 KB
#include "shortcut.h"
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long int lld;
typedef pair<int,long long int> pii;

vector<pii>nei[1000000];
lld max(lld x, lld y){
	if(x<y)return y;
return x;
	
}
lld min(lld x, lld y){
	if(x>y)return y;
return x;
	
}
lld diameter(vector<pii>graph[],int n){
	lld ans=0;
	for(int i=0;i<n;i++){
		queue<pii>q;
		lld dist[n];
		for(int j=0;j<n;j++)dist[j]=-1;
		dist[i]=0;
		q.push(pii(i,0));
		while(!q.empty()){//it++;
			int node=q.front().first;
			lld d=q.front().second;
			//cout<<node<<" "<<d<<endl;
			q.pop();
			if(d>dist[node] && dist[node]!=-1)continue;
			for(int j=0;j<graph[node].size();j++){
				int v=graph[node][j].first;
				if(dist[v]==-1 || dist[v]>graph[node][j].second+d){
					dist[v]=graph[node][j].second+d;
					q.push(pii(v,dist[v]));
				}
			}
		}
		for(int j=0;j<n;j++){
			//cout<<dist[j]<<" ";
			ans=max(ans,dist[j]);
		}//cout<<endl;
	}return ans;
}
long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
	for(int i=0;i<n;i++){
		nei[i+n].push_back(pii(i,d[i]));
		nei[i].push_back(pii(i+n,d[i]));
	}
	for(int i=0;i<n-1;i++){
		nei[i].push_back(pii(i+1,l[i]));
		nei[i+1].push_back(pii(i,l[i]));
	}
	lld ans=1000000000000000000;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			vector<pii> graph[2*n];
			for(int k=0;k<2*n;k++){
				for(int u=0;u<nei[k].size();u++){
					graph[k].push_back(nei[k][u]);
				}
			}
			graph[i].push_back(pii(j,c));
			graph[j].push_back(pii(i,c));
			ans=min(ans,diameter(graph,2*n));
			//cout<<diameter(graph,2*n)<<" "<<i<<" "<<j<<endl;
		}
	}
	ans=min(ans,diameter(nei,2*n));
	//cout<<diameter(nei,2*n)<<endl;
	return ans;
}

Compilation message

shortcut.cpp: In function 'lld diameter(std::vector<std::pair<int, long long int> >*, int)':
shortcut.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<graph[node].size();j++){
                ~^~~~~~~~~~~~~~~~~~~
shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int u=0;u<nei[k].size();u++){
                 ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 23800 KB n = 4, 80 is a correct answer
2 Correct 30 ms 23968 KB n = 9, 110 is a correct answer
3 Correct 26 ms 23968 KB n = 4, 21 is a correct answer
4 Correct 24 ms 23968 KB n = 3, 4 is a correct answer
5 Correct 24 ms 23968 KB n = 2, 62 is a correct answer
6 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
7 Correct 26 ms 23968 KB n = 3, 29 is a correct answer
8 Correct 26 ms 23968 KB n = 2, 3 is a correct answer
9 Correct 27 ms 23968 KB n = 2, 3 is a correct answer
10 Correct 25 ms 24120 KB n = 2, 2000000001 is a correct answer
11 Correct 24 ms 24120 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 24120 KB n = 3, 3000000000 is a correct answer
13 Correct 28 ms 24120 KB n = 3, 3000000000 is a correct answer
14 Correct 28 ms 24128 KB n = 4, 3000000001 is a correct answer
15 Correct 28 ms 24128 KB n = 4, 4000000000 is a correct answer
16 Correct 32 ms 24128 KB n = 5, 4000000000 is a correct answer
17 Correct 31 ms 24128 KB n = 10, 1000000343 is a correct answer
18 Correct 31 ms 24128 KB n = 10, 3189 is a correct answer
19 Correct 31 ms 24128 KB n = 10, 7000000000 is a correct answer
20 Correct 26 ms 24128 KB n = 5, 12 is a correct answer
21 Correct 25 ms 24128 KB n = 5, 25 is a correct answer
22 Correct 24 ms 24128 KB n = 2, 122 is a correct answer
23 Correct 28 ms 24128 KB n = 10, 117 is a correct answer
24 Correct 26 ms 24128 KB n = 10, 336 is a correct answer
25 Correct 26 ms 24128 KB n = 10, 438 is a correct answer
26 Correct 25 ms 24128 KB n = 10, 206 is a correct answer
27 Correct 28 ms 24128 KB n = 10, 636 is a correct answer
28 Correct 25 ms 24128 KB n = 4, 2399 is a correct answer
29 Correct 30 ms 24128 KB n = 10, 10992 is a correct answer
30 Correct 32 ms 24128 KB n = 10, 3112 is a correct answer
31 Execution timed out 2049 ms 24128 KB Time limit exceeded
32 Halted 0 ms 0 KB -