fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int arr[222][222];
  4. int main(){
  5. ios::sync_with_stdio(false);
  6. cin.tie(0),cout.tie(0);
  7. int n;
  8. cin>>n;
  9. for(int i=1;i<n;i++){
  10. for(int j=1;j<=n;j++){
  11. if(i==j){
  12. continue;
  13. }
  14. cin>>arr[i][j];
  15. }
  16. }
  17. for(int i=1;i<=n;i++){
  18. for(int j=1;j<=n;j++){
  19. for(int k=1;k<=n;k++){
  20. if(i==j){
  21. continue;
  22. }
  23. if(i==k || j==k){
  24. continue;
  25. }
  26. if(i>j || i>k){
  27. continue;
  28. }
  29. if(j>k){
  30. return 0;
  31. }
  32. if(arr[i][j]+arr[j][k]<arr[i][k]){
  33. cout<<"Yes";
  34. return 0;
  35. }
  36. }
  37. }
  38. }
  39. cout<<"No";
  40. }
Success #stdin #stdout 0s 5324KB
stdin
4
25 40 65
30 55
25
stdout
Yes