Submission #4017061
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)
int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,m;
cin>>n>>m;
vl a(m),b(m),t(m);
vvl dist(n,vl(n,LINF));
rep(i,m){
cin>>a[i]>>b[i]>>t[i];
a[i]--;b[i]--;
dist[a[i]][b[i]]=t[i];
dist[b[i]][a[i]]=t[i];
}
rep(i,n)dist[i][i]=0;
rep(i,n) rep(j,n) rep(k,n)chmin(dist[i][j],dist[i][k]+dist[k][j]);
ll ans=LINF;
rep(i,n){
ll saiaku=0;
rep(j,n)chmax(saiaku,dist[i][j]);
chmin(ans,saiaku);
}
cout<<ans<<endl;
}
Submission Info
Submission Time |
|
Task |
D - バスと避けられない運命 |
User |
makecir |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1800 Byte |
Status |
WA |
Exec Time |
54 ms |
Memory |
2048 KB |
Judge Result
Set Name |
All |
Score / Max Score |
0 / 100 |
Status |
|
Set Name |
Test Cases |
All |
sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
1 ms |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
sample_03.txt |
AC |
1 ms |
256 KB |
test_01.txt |
AC |
1 ms |
256 KB |
test_02.txt |
WA |
40 ms |
1024 KB |
test_03.txt |
WA |
54 ms |
2048 KB |
test_04.txt |
AC |
16 ms |
640 KB |
test_05.txt |
WA |
18 ms |
1024 KB |
test_06.txt |
WA |
3 ms |
384 KB |
test_07.txt |
WA |
41 ms |
1664 KB |
test_08.txt |
WA |
2 ms |
256 KB |
test_09.txt |
WA |
12 ms |
896 KB |
test_10.txt |
WA |
3 ms |
384 KB |
test_11.txt |
WA |
3 ms |
384 KB |
test_12.txt |
WA |
23 ms |
768 KB |
test_13.txt |
WA |
3 ms |
384 KB |
test_14.txt |
WA |
4 ms |
512 KB |
test_15.txt |
WA |
38 ms |
1664 KB |
test_16.txt |
WA |
4 ms |
512 KB |
test_17.txt |
WA |
13 ms |
896 KB |
test_18.txt |
WA |
22 ms |
768 KB |
test_19.txt |
WA |
4 ms |
512 KB |
test_20.txt |
AC |
4 ms |
512 KB |
test_21.txt |
AC |
1 ms |
256 KB |
test_22.txt |
WA |
9 ms |
512 KB |
test_23.txt |
WA |
1 ms |
256 KB |
test_24.txt |
WA |
40 ms |
1024 KB |
test_25.txt |
WA |
40 ms |
1024 KB |
test_26.txt |
WA |
8 ms |
512 KB |
test_27.txt |
WA |
11 ms |
640 KB |
test_28.txt |
WA |
40 ms |
1024 KB |
test_29.txt |
WA |
40 ms |
1024 KB |
test_30.txt |
WA |
3 ms |
384 KB |
test_31.txt |
WA |
1 ms |
256 KB |
test_32.txt |
WA |
40 ms |
1024 KB |
test_33.txt |
WA |
40 ms |
1024 KB |
test_34.txt |
WA |
2 ms |
256 KB |
test_35.txt |
WA |
7 ms |
512 KB |
test_36.txt |
WA |
40 ms |
1024 KB |