fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n = 9, mt[10][10], fr[10][10] = {0} ;
  6. for (int i = 1; i <= n; ++i) {
  7. for (int j = 1; j <= n; ++j) {
  8. cin >> mt[i][j];
  9. }
  10. }
  11. for (int i = 1; i <= n; ++i) {
  12. for (int j = 1; j <= n; ++j) {
  13. ++fr[i][mt[i][j]];
  14. ++fr[j][mt[i][j]];
  15. if (fr[j][mt[i][j]] > 2) {
  16. n= 0;
  17. cout << "incorect";
  18. }
  19. }
  20. for (int k = 1; k <= n; ++k) {
  21. if (fr[i][k] > 2) {
  22. cout << "incorect";
  23. n = 0;
  24. }
  25. }
  26. }
  27.  
  28. int endL = 3;
  29. if (n > 0) {
  30. int startL = 1, startC= 1,endC= 3,fr2[10]={0}, a= 1;
  31. while (a < 9) {
  32. for (int i = startL; i <= endL; ++i) {
  33. for (int j = startC; j <= endC; ++j) {
  34. ++fr2[mt[i][j]];
  35. if (fr2[mt[i][j]] > a) {
  36. a = 10;
  37. endL = 0;
  38. }
  39. }
  40. }
  41. if (endC < 9) {
  42. ++a;
  43. startC += 3;
  44. endC += 3;
  45. } else if (endC == 9 && endL < 9) {
  46. ++a;
  47. startL += 3;
  48. endL += 3;
  49. endC = 3;
  50. startL = 1;
  51. }
  52. }
  53. if (endL > 0) {
  54. cout << "corect";
  55. } else {
  56. cout << "incorect";
  57. }
  58. }
  59. return 0;
  60. }
Success #stdin #stdout 0s 544KB
stdin
7 2 8 6 5 9 3 1 4
1 4 5 7 3 8 2 6 9
2 9 7 3 6 1 8 4 5
5 8 3 9 4 2 6 7 1
6 1 4 5 8 7 9 2 3
9 7 2 8 1 5 4 3 6
4 5 6 2 7 3 1 9 8
8 3 1 4 9 6 7 5 2
3 6 9 1 2 4 5 8 7
stdout
incorect