結果
| 問題 |
No.3319 Iwaijkstra
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-31 21:14:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,418 bytes |
| コンパイル時間 | 3,352 ms |
| コンパイル使用メモリ | 289,180 KB |
| 実行使用メモリ | 813,776 KB |
| 最終ジャッジ日時 | 2025-10-31 21:14:26 |
| 合計ジャッジ時間 | 7,372 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | MLE * 1 -- * 57 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// https://yukicoder.me/problems/no/3319
int iwaijkstra(int n, int m, vector<int> x, vector<int> l, vector<int> r, vector<int> c) {
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
que.emplace(0, 1);
vector<long long> dist(n, 1e18), vis(n);
dist[0] = 0;
int ans(0);
while (!que.empty()) {
auto [a, b] = que.top();
que.pop(), ++ans;
if (ans >= 5e6 || que.size() >= 5e6) return 5e6;
for (int i(0); i < n; ++i)
if (dist[i] < a) vis[i] = true;
if (vis[b - 1]) continue;
for (int i(0); i < m; ++i)
if (x[i] == b) {
for (int j(l[i] - 1); j < r[i]; ++j)
if (!vis[j]) {
dist[j] = min(dist[j], a + c[i]);
que.emplace(a + c[i], j + 1);
}
}
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> x, l, r, c;
for (int i = 0; i < m; i++) {
int xx, ll, rr, cc;
cin >> xx >> ll >> rr >> cc;
x.push_back(xx);
l.push_back(ll);
r.push_back(rr);
c.push_back(cc);
}
int ans = iwaijkstra(n, m, x, l, r, c);
cout << (ans == 5e6 ? "Too Many" : to_string(ans)) << endl;
}