fork download
  1. /*
  2. Task: Problem 7.08
  3. Date: Dec 24, 2020
  4. Author: aLittleLove (Minh Vu)
  5. */
  6.  
  7. #include<bits/stdc++.h>
  8.  
  9. using namespace std;
  10. const int N = 2e3 + 5;
  11.  
  12. double a[N][N];
  13.  
  14. int main()
  15. {
  16. ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  17. //freopen("input.txt","r",stdin);
  18. int n; cin >> n >> n;
  19. for (int i=0; i<n; i++)
  20. for (int j=0; j<n; j++)
  21. cin >> a[i][j];
  22. int col = -1; //danh dau cot duy nhat co phan tu bat ki
  23. for (int i=0; i<n; i++)
  24. for (int j=0; j<n; j++)
  25. {
  26. if (i==j && a[i][j]!=1) //duong cheo chinh
  27. {
  28. cout << "No";
  29. return 0;
  30. }
  31. if (i<j && a[i][j]!=0) //phan tu phia tren duong cheo -> i<j
  32. {
  33. cout << "No";
  34. return 0;
  35. }
  36. if (i>j && a[i][j]!=0) //phan tu phia duoi duong cheo -> i>j
  37. {
  38. if (col==-1) col = j; //chua danh dau cot nao
  39. else if (col!=j) //da co cot duoc danh dau nhung khong phai cot j
  40. {
  41. cout << "No";
  42. return 0;
  43. }
  44. }
  45. }
  46. cout << "Yes";
  47. return 0;
  48. }
Success #stdin #stdout 0s 4776KB
stdin
3 3
1 0 0
0 1 0
1 1 1.0
stdout
No