Submission #533052
Source Code Expand
#include <string> #include <vector> #include<iostream> #include<cstdio> #include<cstdlib> #include<stack> #include<queue> #include<cmath> #include<algorithm> #include<functional> #include<list> #include<deque> #include<bitset> #include<set> #include<map> #include<unordered_map> #include<cstring> #include<sstream> #include<complex> #include<iomanip> #include<numeric> #define X first #define Y second #define pb push_back #define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X)) #define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X)) #define repe(X,Y) for ((X) = 0;(X) < (Y);++(X)) #define peat(X,Y) for (;(X) < (Y);++(X)) #define all(X) (X).begin(),(X).end() #define rall(X) (X).rbegin(),(X).rend() #define eb emplace_back #define UNIQUE(X) (X).erase(unique(all(X)),(X).end()) using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<class T> using vv=vector<vector<T>>; template<class T> ostream& operator<<(ostream &os, const vector<T> &t) { os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;} template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";} const ll MOD=1e9+7; const int INF=1e8; int d[33][33],a[33][33]; int main(){ ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(0); int T; cin>>T; while(T--){ int n,x; cin>>n; rep(i,n)rep(j,n){ cin>>x; if(x<0) x=INF; a[i][j]=d[i][j]=x; } rep(i,n)d[i][i]=0; rep(k,n)rep(i,n)rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]); int f=1; //rep(i,n){rep(j,n)cout<<d[i][j]<<",";cout<<endl;} rep(i,n)rep(j,n) if(a[i][j]!=d[i][j]) f=0; cout<<(f?"YES":"NO")<<endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 最短経路 |
User | nuip |
Language | C++11 (GCC 4.9.2) |
Score | 100 |
Code Size | 1811 Byte |
Status | AC |
Exec Time | 32 ms |
Memory | 928 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_sample.txt, 10_random_00.txt, 10_random_01.txt, 10_random_02.txt, 10_random_03.txt, 10_random_04.txt, 10_random_05.txt, 10_random_06.txt, 10_random_07.txt, 10_random_08.txt, 10_random_09.txt, 10_random_10.txt, 10_random_11.txt, 10_random_12.txt, 10_random_13.txt, 10_random_14.txt, 10_random_15.txt, 10_random_16.txt, 10_random_17.txt, 10_random_18.txt, 10_random_19.txt, 10_random_20.txt, 10_random_21.txt, 10_random_22.txt, 10_random_23.txt, 10_random_24.txt, 10_random_25.txt, 10_random_26.txt, 10_random_27.txt, 10_random_28.txt, 10_random_29.txt, 22_random_30.txt, 22_random_31.txt, 23_coplete_32.txt, 23_coplete_33.txt, 24_path_34.txt, 24_path_35.txt, 25_tree_36.txt, 25_tree_37.txt, 26_noedge_38.txt, 27_dot_39.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample.txt | AC | 26 ms | 916 KB |
10_random_00.txt | AC | 32 ms | 792 KB |
10_random_01.txt | AC | 31 ms | 924 KB |
10_random_02.txt | AC | 31 ms | 796 KB |
10_random_03.txt | AC | 31 ms | 792 KB |
10_random_04.txt | AC | 31 ms | 724 KB |
10_random_05.txt | AC | 31 ms | 920 KB |
10_random_06.txt | AC | 30 ms | 912 KB |
10_random_07.txt | AC | 31 ms | 800 KB |
10_random_08.txt | AC | 29 ms | 920 KB |
10_random_09.txt | AC | 30 ms | 928 KB |
10_random_10.txt | AC | 30 ms | 916 KB |
10_random_11.txt | AC | 30 ms | 844 KB |
10_random_12.txt | AC | 29 ms | 928 KB |
10_random_13.txt | AC | 31 ms | 796 KB |
10_random_14.txt | AC | 29 ms | 928 KB |
10_random_15.txt | AC | 31 ms | 796 KB |
10_random_16.txt | AC | 31 ms | 800 KB |
10_random_17.txt | AC | 31 ms | 800 KB |
10_random_18.txt | AC | 31 ms | 920 KB |
10_random_19.txt | AC | 30 ms | 800 KB |
10_random_20.txt | AC | 31 ms | 800 KB |
10_random_21.txt | AC | 31 ms | 804 KB |
10_random_22.txt | AC | 31 ms | 928 KB |
10_random_23.txt | AC | 31 ms | 812 KB |
10_random_24.txt | AC | 31 ms | 804 KB |
10_random_25.txt | AC | 30 ms | 920 KB |
10_random_26.txt | AC | 31 ms | 920 KB |
10_random_27.txt | AC | 30 ms | 796 KB |
10_random_28.txt | AC | 30 ms | 920 KB |
10_random_29.txt | AC | 30 ms | 924 KB |
22_random_30.txt | AC | 30 ms | 924 KB |
22_random_31.txt | AC | 29 ms | 928 KB |
23_coplete_32.txt | AC | 31 ms | 924 KB |
23_coplete_33.txt | AC | 31 ms | 800 KB |
24_path_34.txt | AC | 31 ms | 920 KB |
24_path_35.txt | AC | 31 ms | 920 KB |
25_tree_36.txt | AC | 30 ms | 928 KB |
25_tree_37.txt | AC | 30 ms | 928 KB |
26_noedge_38.txt | AC | 28 ms | 924 KB |
27_dot_39.txt | AC | 24 ms | 928 KB |