Submission #58695774
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,l,r) for(int i=(l);i>=(r);--i)
#define repn(i,n) for(int i=0;i<(n);++i)
#define sizc(x) ((int)x.size())
#define allc(x) x.begin(),x.end()
#define fir first
#define sec second
constexpr int N = 305, M = 2e5+5;
int n,m,q;
struct star{
int u,v,w;
}e[M];
bool ban[M];
ll dis[N][N];
int op[M],x[M],y[M];
ll ans[M];
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>m>>q;
rep(i,1,m)cin>>e[i].u>>e[i].v>>e[i].w;
rep(i,1,n)rep(j,1,n)dis[i][j]=1e18;
rep(i,1,n)dis[i][i]=0;
rep(i,1,q){
cin>>op[i]>>x[i];
if(op[i]==2)cin>>y[i];
if(op[i]==1)ban[x[i]]=1;
}
rep(i,1,m)if(!ban[i]){
int u=e[i].u,v=e[i].v,w=e[i].w;
dis[u][v]=dis[v][u]=w;
}
rep(k,1,n)rep(i,1,n)rep(j,1,n)dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
per(i,q,1){
if(op[i]==1){
int u=e[x[i]].u,v=e[x[i]].v,w=e[x[i]].w;
rep(a,1,n)rep(b,1,n){
dis[a][b]=min(dis[a][b],dis[a][u]+dis[v][b]+w);
dis[a][b]=min(dis[a][b],dis[a][v]+dis[u][b]+w);
}
}
else ans[i]=dis[x[i]][y[i]];
}
rep(i,1,q)if(op[i]==2){
if(ans[i]<1e18)cout<<ans[i]<<'\n';
else cout<<"-1\n";
}
}
Submission Info
Submission Time |
|
Task |
F - Road Blocked |
User |
KnownError_ |
Language |
C++ 20 (gcc 12.2) |
Score |
550 |
Code Size |
1571 Byte |
Status |
AC |
Exec Time |
79 ms |
Memory |
8644 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
550 / 550 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt |
All |
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, sample_02.txt |
Case Name |
Status |
Exec Time |
Memory |
random_01.txt |
AC |
70 ms |
8076 KB |
random_02.txt |
AC |
70 ms |
8088 KB |
random_03.txt |
AC |
71 ms |
8136 KB |
random_04.txt |
AC |
74 ms |
8556 KB |
random_05.txt |
AC |
42 ms |
7856 KB |
random_06.txt |
AC |
52 ms |
8068 KB |
random_07.txt |
AC |
68 ms |
8040 KB |
random_08.txt |
AC |
73 ms |
8636 KB |
random_09.txt |
AC |
74 ms |
8052 KB |
random_10.txt |
AC |
74 ms |
8064 KB |
random_11.txt |
AC |
74 ms |
8204 KB |
random_12.txt |
AC |
77 ms |
8644 KB |
random_13.txt |
AC |
33 ms |
7776 KB |
random_14.txt |
AC |
40 ms |
7744 KB |
random_15.txt |
AC |
38 ms |
7796 KB |
random_16.txt |
AC |
47 ms |
8084 KB |
random_17.txt |
AC |
73 ms |
8108 KB |
random_18.txt |
AC |
70 ms |
8172 KB |
random_19.txt |
AC |
73 ms |
8104 KB |
random_20.txt |
AC |
71 ms |
8108 KB |
random_21.txt |
AC |
73 ms |
8172 KB |
random_22.txt |
AC |
71 ms |
8156 KB |
random_23.txt |
AC |
70 ms |
8196 KB |
random_24.txt |
AC |
70 ms |
8220 KB |
random_25.txt |
AC |
79 ms |
8640 KB |
random_26.txt |
AC |
69 ms |
8156 KB |
random_27.txt |
AC |
1 ms |
3528 KB |
sample_01.txt |
AC |
1 ms |
3656 KB |
sample_02.txt |
AC |
1 ms |
3536 KB |