結果
| 問題 | 
                            No.2640 traO Stamps
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Kude
                         | 
                    
| 提出日時 | 2024-02-19 21:41:41 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 70 ms / 2,000 ms | 
| コード長 | 1,703 bytes | 
| コンパイル時間 | 3,191 ms | 
| コンパイル使用メモリ | 275,592 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-09-29 01:36:49 | 
| 合計ジャッジ時間 | 7,517 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 33 | 
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
constexpr long long INF = 1002003004005006007;
ll dist[200][200];
} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  rep(i, 200) rep(j, 200) dist[i][j] = INF;
  rep(i, 200) dist[i][i] = 0;
  int n, m, k;
  cin >> n >> m >> k;
  VI pos(k + 1);
  rep(i, k + 1) cin >> pos[i], pos[i]--;
  rep(_, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    chmin<ll>(dist[a][b], c);
    chmin<ll>(dist[b][a], c);
  }
  rep(k, n) rep(i, n) rep(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);
  fenwick_tree<ll> ft(k);
  rep(i, k) ft.add(i, dist[pos[i]][pos[i+1]]);
  int q;
  cin >> q;
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      y--;
      if (x) ft.add(x-1, -dist[pos[x-1]][pos[x]]);
      if (x < k) ft.add(x, -dist[pos[x]][pos[x+1]]);
      pos[x] = y;
      if (x) ft.add(x-1, dist[pos[x-1]][pos[x]]);
      if (x < k) ft.add(x, dist[pos[x]][pos[x+1]]);
    } else {
      cout << ft.sum(x, y) << '\n';
    }
  }
}
            
            
            
        
            
Kude