QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268209#5081. Forbidden TurnsSTnofarjo#Compile Error//C++201.5kb2023-11-28 13:26:252023-11-28 13:26:25

Judging History

你现在查看的是最新测评结果

  • [2023-11-28 13:26:25]
  • 评测
  • [2023-11-28 13:26:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int INF = 2e9;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	int m, n, k, v, w;
	cin >> m >> n >> k;
	cin >> v >> w;

	vector<vector<pair<int, int>>> from(n);

	vector<pair<int, int>> edges(m);
	map<pair<int, int>, int> edge_idx;
	vector<int> dis(m, INF);
	for (int i = 0; i < m; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		edges[i] = make_pair(x, y);
		from[x].emplace_back(y, c);
		edge_idx[make_pair(x, y)] = i;
	}

	set<int> forbid[m];
	for (int i = 0; i < k; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		forbid[edge_idx[make_pair(x, y)]].insert(edge_idx[make_pair(y, z)]);
	}

	set<pair<int, int>> Q;
	for (auto nx : from[v]) {
		int cur_id = edge_idx[make_pair(v, nx.first)];
		dis[cur_id] = nx.second;
		Q.emplace(dis[cur_id], cur_id);
	}

	while (!Q.empty()) {
		auto now = Q.begin();
		Q.erase(Q.begin());
		int cur_id = now->second;
		int v = edges[cur_id].second;
		for (auto c : from[v]) {
			int nx_edge_id = edge_idx[make_pair(v, c.first)];
			if (forbid[cur_id].count(nx_edge_id)) continue;
			if (dis[nx_edge_id] > dis[cur_id] + c.second) {
				Q.erase(make_pair(dis[nx_edge_id], nx_edge_id));
				dis[nx_edge_id] = dis[cur_id] + c.second;
				Q.emplace(dis[nx_edge_id], nx_edge_id);
			}
		}
	}

	int ans = INF;
	for (int i = 0; i < m; i++) {
		if (edges[i].second == w) {
			ans = min(ans, dis[i]);
		}
	}
	if (ans == INF) {
		cout << -1 << '\n';
		return;
	}
	cout << ans << '\n';
}

Details

answer.code: In function ‘int main()’:
answer.code:64:17: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
   64 |                 return;
      |                 ^~~~~~