답안 #54265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54265 2018-07-03T01:12:57 Z Crown Commuter Pass (JOI18_commuter_pass) C++14
0 / 100
46 ms 2400 KB
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 305;

ll dist[maxn][maxn];

int s, t, u, v;

int main()
{
	int n, m; scanf("%d %d", &n, &m);
	scanf("%d %d %d %d", &s, &t, &u, &v);
	for(int i = 1; i<= n; i++)
		for(int j = 1; j<= n; j++)
			dist[i][j] = 1e18;
	while(m--)
	{
		int u, v; scanf("%d %d", &u, &v);
		int w; scanf("%d", &w);
		dist[u][v] = dist[v][u] = w;
	}
	for(int k = 1; k<= n; k++)
		for(int i = 1; i<= n; i++)
			for(int j = 1; j<= n; j++)
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
	
	ll best = dist[u][v];
	for(int u1 = 1; u1<= n; u1++)
		for(int u2 = 1; u2<= n; u2++)
		{
			if(dist[s][u1]+dist[u1][u2]+dist[u2][t] == dist[s][t])
			{
				best = min(best, dist[u][u1]+dist[u2][v]);
			}
		}
	printf("%lld\n", best);
}

Compilation message

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:17:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, m; scanf("%d %d", &n, &m);
            ~~~~~^~~~~~~~~~~~~~~~~
commuter_pass.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d", &s, &t, &u, &v);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~
commuter_pass.cpp:25:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int w; scanf("%d", &w);
          ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 2052 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 2400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -