結果
問題 |
No.3103 Butterfly Effect
|
ユーザー |
|
提出日時 | 2025-04-11 22:40:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,439 bytes |
コンパイル時間 | 2,313 ms |
コンパイル使用メモリ | 206,300 KB |
実行使用メモリ | 66,068 KB |
最終ジャッジ日時 | 2025-04-11 22:40:36 |
合計ジャッジ時間 | 25,257 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 WA * 18 RE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d%d%d", &p, &x, &y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef pair<int, pair<int, int> > piii; typedef long long ll; const int N = 2000086, MOD = 998244353, INF = 0x3f3f3f3f; ll res; int n, m, cnt, w[N]; int t[N]; bool st[N]; int main() { cin >> n >> m; for (int i = 1; i < n + 1; i++) t[i] = INF; t[1] = 0; res = 1; vector<set<pii, less<pii> > > e(n + 10); priority_queue<pii, vector<pii>, greater<pii> > q; for (int i = 1; i < m + 1; i++) { int p, x, y; scanf("%d%d%d", &p, &x, &y); if (p > min(t[x], t[y])) { if (t[x] > t[y]) swap(x, y); if (t[x] < p && t[y] > p) { res += t[y] == INF; t[y] = p; q.push({t[y], y}); while (q.size()) { auto u = q.top().second; q.pop(); while (e[u].size() && e[u].begin()->first > t[u]) { auto v = *e[u].begin(); e[u].erase(v); e[v.second].erase({v.first, u}); assert(t[v.second] > t[u]); res += t[v.second] == INF; t[v.second] = v.first; q.push({v.first, v.second}); } } } } else e[x].insert({p, y}), e[y].insert({p, x}); printf("%lld\n", res); } return 0; }