結果
問題 | No.2640 traO Stamps |
ユーザー |
![]() |
提出日時 | 2024-02-19 21:47:38 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,928 bytes |
コンパイル時間 | 5,242 ms |
コンパイル使用メモリ | 314,400 KB |
実行使用メモリ | 10,012 KB |
最終ジャッジ日時 | 2024-09-29 01:44:13 |
合計ジャッジ時間 | 10,605 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 6 WA * 27 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; //using mint = modint998244353; //const int mod = 998244353; //using mint = modint1000000007; //const int mod = 1000000007; //const int INF = 1e9; const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } template<typename T> void warshallFloyd(int n, std::vector<std::vector<T>> &d, T inf) { for (int k = 0; k < n; ++k)for (int i = 0; i < n; ++i)for (int j = 0; j < n; ++j) { if (inf == d[i][k] || inf == d[k][j])continue; d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]); } } long long op(long long a, long long b) { return a + b; } long long e() { return 0; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; vector<int>s(k + 1); rep(i, k + 1)cin >> s[i], s[i]--; vector d(n, vector<long long>(n, LINF)); rep(i, n)d[i][i] = 0; rep(i, m) { int a, b, c; cin >> a >> b >> c; a--, b--; d[a][b] = c; d[b][a] = c; } warshallFloyd(n, d, LINF); vector<long long>a(k); rep(i, k)a[i] = d[s[i]][s[i + 1]]; segtree<long long, op, e>seg(a); int q; cin >> q; while (q--) { int t, x, y; cin >> t >> x >> y; if (1 == t) { y--; s[x] = y; if (0 != x) { //seg.set(x - 1, d[s[x - 1]][s[x]]); } if (k - 1 != x) { //seg.set(x, d[s[x]][s[x + 1]]); } } else { long long ans = seg.prod(x, y); cout << ans << endl; } } return 0; }