結果
| 問題 | No.3488 距離の公理 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-03 21:23:40 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 826 bytes |
| 記録 | |
| コンパイル時間 | 3,264 ms |
| コンパイル使用メモリ | 215,532 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-03 21:23:57 |
| 合計ジャッジ時間 | 3,987 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<vector<long long>> D(N,vector<long long>(N));
for(auto &h : D) for(auto &w : h) cin >> w;
bool three = true,four = true;
for(int i=0; i<N; i++) for(int k=0; k<N; k++){
if((i == k) != (D.at(i).at(k)==0)){cout << "No\nNo\n"; return 0;}
if(D.at(i).at(k) != D.at(k).at(i)){cout << "No\nNo\n"; return 0;}
}
for(int i=0; i<N; i++) for(int k=0; k<N; k++) for(int l=0; l<N; l++){
if(D.at(i).at(k) > D.at(i).at(l)+D.at(l).at(k)) three = false;
if(D.at(i).at(k) > max(D.at(i).at(l),D.at(l).at(k))) four = false;
}
if(three) cout << "Yes\n";
else cout << "No\n";
if(four) cout << "Yes\n";
else cout << "No\n";
}