Submission #67963958
Source Code Expand
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
namespace mlp = boost::multiprecision;
using bint = mlp::cpp_int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using mint = modint998244353;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define rep1(i,n) for (int i=1;i<(int)(n);i++)
#define rrep(i,n) for (ll i=n-1;i>=0;i--)
#define rrep1(i,n) for (ll i=n-1;i>0;i--)
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define pi 3.141592653589793238L
//対オーバーフロー兵器
#define int long long
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N,M; cin>>N>>M;
vector<vector<ll> > A(N,vector<ll>(N,2e+18));
rep(i,N) A[i][i]=0;
ll ans=0;
rep(i,M){
int a,b,c; cin>>a>>b>>c; a--; b--;
A[a][b]=c; A[b][a]=c;
}
ll K,T; cin>>K>>T;
vector<int> D(K);
rep(i,K) cin>>D[i];
rep(i,K) D[i]--;
for (int i=0;i<K;i++){
for (int j=i+1;j<K;j++){
if (T<A[D[i]][D[j]]){
chmin(A[D[i]][D[j]],T);
chmin(A[D[j]][D[i]],T);
}
}
}
rep(k,N)rep(i,N)rep(j,N){
if (A[i][j]>A[i][k]+A[k][j]){
if (A[i][j]<1e+18) ans-=(ll)2*A[i][j];
A[i][j]=A[i][k]+A[k][j];
}
}
ll prev=-1;
bool update=true;
int Q; cin>>Q;
rep(w,Q){
int q; cin>>q;
if (q==1){
int x,y,t; cin>>x>>y>>t; x--; y--;
if (A[x][y]>t) update=true;
chmin(A[x][y],t);
chmin(A[y][x],t);
}
if (q==2){
int x; cin>>x; x--;
rep(i,K){
if (A[x][D[i]]>T) update=true;
chmin(A[x][D[i]],T);
chmin(A[D[i]][x],T);
}
K++; D.push_back(x);
}
if (q==3){
if (!update){cout<<prev<<endl; continue;}
update=false;
ll ans=0;
rep(k,N)rep(i,N)rep(j,N){
chmin(A[i][j],A[i][k]+A[k][j]);
}
rep(i,N)rep(j,N) if(A[i][j]<1e+18) ans+=A[i][j];
cout<<ans<<endl;
prev=ans;
}
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
E - Development |
| User |
Fkun |
| Language |
C++ 20 (gcc 12.2) |
| Score |
0 |
| Code Size |
2170 Byte |
| Status |
WA |
| Exec Time |
3865 ms |
| Memory |
5380 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
0 / 450 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt |
| All |
hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, sample_01.txt |
| Case Name |
Status |
Exec Time |
Memory |
| hand.txt |
AC |
1 ms |
3456 KiB |
| random_01.txt |
TLE |
3862 ms |
5216 KiB |
| random_02.txt |
TLE |
3862 ms |
3912 KiB |
| random_03.txt |
TLE |
3862 ms |
5260 KiB |
| random_04.txt |
TLE |
3862 ms |
4856 KiB |
| random_05.txt |
TLE |
3862 ms |
5268 KiB |
| random_06.txt |
TLE |
3862 ms |
3872 KiB |
| random_07.txt |
TLE |
3862 ms |
5304 KiB |
| random_08.txt |
TLE |
3862 ms |
5156 KiB |
| random_09.txt |
TLE |
3862 ms |
5256 KiB |
| random_10.txt |
TLE |
3862 ms |
3948 KiB |
| random_11.txt |
TLE |
3862 ms |
5300 KiB |
| random_12.txt |
TLE |
3862 ms |
4388 KiB |
| random_13.txt |
TLE |
3862 ms |
5260 KiB |
| random_14.txt |
WA |
2792 ms |
3596 KiB |
| random_15.txt |
TLE |
3862 ms |
5280 KiB |
| random_16.txt |
TLE |
3862 ms |
4560 KiB |
| random_17.txt |
TLE |
3862 ms |
5380 KiB |
| random_18.txt |
TLE |
3862 ms |
4772 KiB |
| random_19.txt |
TLE |
3862 ms |
5304 KiB |
| random_20.txt |
TLE |
3862 ms |
4716 KiB |
| random_21.txt |
WA |
65 ms |
3876 KiB |
| random_22.txt |
TLE |
3865 ms |
4064 KiB |
| random_23.txt |
WA |
214 ms |
4100 KiB |
| random_24.txt |
TLE |
3862 ms |
4132 KiB |
| random_25.txt |
TLE |
3862 ms |
5280 KiB |
| random_26.txt |
TLE |
3862 ms |
5216 KiB |
| random_27.txt |
TLE |
3862 ms |
5336 KiB |
| sample_01.txt |
AC |
1 ms |
3460 KiB |