京都大学プログラミングコンテスト2015

Submission #1692359

Source codeソースコード

#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
    int t;cin>>t;
    rep(_,t){
        int n; cin>>n;
        vector<vector<int>>d(n,vector<int>(n,INF));
        bool flag=true;
        rep(i,n)rep(j,n)cin>>d[i][j];
        rep(i,n)rep(j,n)if(d[i][j]==-1)d[i][j]=INF;
        rep(i,n)if(d[i][i]!=0)flag=false;
        rep(k,n)rep(i,n)rep(j,n)
        if(d[i][j]>d[i][k]+d[k][j]&&i!=j&&k!=j&&k!=i)
            flag=false;
        if(!flag)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}

Submission

Task問題 C - 最短経路
User nameユーザ名 yebityon
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 1349 Byte
File nameファイル名
Exec time実行時間 9 ms
Memory usageメモリ使用量 384 KB

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample.txt AC 1 ms 256 KB
10_random_00.txt AC 8 ms 256 KB
10_random_01.txt AC 8 ms 256 KB
10_random_02.txt AC 8 ms 256 KB
10_random_03.txt AC 8 ms 256 KB
10_random_04.txt AC 8 ms 256 KB
10_random_05.txt AC 8 ms 256 KB
10_random_06.txt AC 8 ms 256 KB
10_random_07.txt AC 8 ms 256 KB
10_random_08.txt AC 8 ms 256 KB
10_random_09.txt AC 8 ms 256 KB
10_random_10.txt AC 8 ms 256 KB
10_random_11.txt AC 8 ms 256 KB
10_random_12.txt AC 8 ms 256 KB
10_random_13.txt AC 8 ms 256 KB
10_random_14.txt AC 8 ms 256 KB
10_random_15.txt AC 8 ms 256 KB
10_random_16.txt AC 8 ms 256 KB
10_random_17.txt AC 8 ms 256 KB
10_random_18.txt AC 9 ms 384 KB
10_random_19.txt AC 8 ms 256 KB
10_random_20.txt AC 8 ms 256 KB
10_random_21.txt AC 8 ms 256 KB
10_random_22.txt AC 8 ms 256 KB
10_random_23.txt AC 8 ms 256 KB
10_random_24.txt AC 8 ms 256 KB
10_random_25.txt AC 8 ms 256 KB
10_random_26.txt AC 8 ms 256 KB
10_random_27.txt AC 8 ms 256 KB
10_random_28.txt AC 8 ms 256 KB
10_random_29.txt AC 8 ms 256 KB
22_random_30.txt AC 8 ms 256 KB
22_random_31.txt AC 8 ms 256 KB
23_coplete_32.txt AC 9 ms 256 KB
23_coplete_33.txt AC 9 ms 256 KB
24_path_34.txt AC 8 ms 256 KB
24_path_35.txt AC 8 ms 256 KB
25_tree_36.txt AC 7 ms 256 KB
25_tree_37.txt AC 7 ms 256 KB
26_noedge_38.txt AC 7 ms 256 KB
27_dot_39.txt AC 1 ms 256 KB