답안 #147487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147487 2019-08-29T17:56:07 Z luciocf Ceste (COCI17_ceste) C++14
16 / 160
104 ms 23824 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, int> pii;

const int maxn = 110;
const int maxv = 1e4+10;
const ll inf = 1e18+10;

int n, m;

ll dist[maxn], ans[maxn];

bool mark[maxn][maxn];

vector<pair<pii, int>> grafo[maxn];

void dijkstra(void)
{
	for (int i = 1; i <= n; i++)
		dist[i] = inf;

	priority_queue<pair<pii, pii>, vector<pair<pii, pii>>, greater<pair<pii, pii>>> fila;

	dist[1] = 0, fila.push({{0, 1}, {0, 0}});

	while (!fila.empty())
	{
		int u = fila.top().first.second, sum_t = fila.top().second.first, sum_c = fila.top().second.second;
		ll cost = fila.top().first.first;

		fila.pop();

		if (sum_t > maxv || mark[u][sum_t]) continue;

		if (!ans[u]) ans[u] = cost;
		mark[u][sum_t] = 1;

		for (auto pp: grafo[u])
		{
			int v = pp.second, t = pp.first.first, c = pp.first.second;

			fila.push({{1ll*(sum_t+t)*(sum_c+c), v}, {sum_t+t, sum_c+c}});
		}
	}
}

int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);

	for (int i = 1; i <= m; i++)
	{
		int u, v, t, c;
		scanf("%d %d %d %d", &u, &v, &t, &c);

		grafo[u].push_back({{t, c}, v});
		grafo[v].push_back({{t, c}, u});
	}

	dijkstra();

	for (int i = 2; i <= n; i++)
	{
		if (ans[i] == 0) printf("-1\n");
		else printf("%lld\n", ans[i]);
	}
}

Compilation message

ceste.cpp: In function 'int main()':
ceste.cpp:53:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
ceste.cpp:58:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &u, &v, &t, &c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 1648 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 1012 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 2536 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 23824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -