Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MAXN 1234
  4.  
  5. int a[MAXN][MAXN];
  6.  
  7. int main() {
  8.  
  9. int n, m, i, j, ans = 1, pet = 0, odn = 0;
  10. scanf("%d", &n);
  11. for (i = 1; i <= n; ++i) {
  12. for (j = 1; j <= n; ++j) {
  13. scanf("%d", &a[i][j]);
  14. }
  15. }
  16.  
  17. for (i = 1; i <= n; ++i) {
  18. for (j = 1; j <= n; ++j) {
  19. if (i == j && a[i][j] != 0) {
  20. ans = 0;
  21. pet = pet + a[i][j];
  22. }
  23. if (a[i][j] > a[j][i]) {
  24. ans = 0;
  25. odn = odn + a[i][j] - a[j][i];
  26. }
  27. if (a[i][j] < a[j][i]) {
  28. ans = 0;
  29. odn = odn + a[j][i] - a[i][j];
  30. }
  31. }
  32. }
  33. if (ans == 0) {
  34. printf("Incorrect\n");
  35. printf("%d %d", pet, odn / 2);
  36. }
  37. else {
  38. printf("Correct");
  39. }
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement