URI Solution 1383 Sudoku - Solution in C++ | Ad Hoc
URI Online Judge Solution Sudoku | Ad Hoc
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1383
Problem Name: URI Problem Sudoku
Problem Number : URI Problem 1383 Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1383 Code in CPP:
#include <iostream> #include <string> using namespace std; int main(int argc, char const *argv[]) { int n, i, j, k, sum = 285, cnt = 0; int matriz[9][9]; string s = ""; cin >> n; while(n--) { for(i = 0; i < 9; i++) for(j = 0; j < 9; j++) cin >> matriz[i][j]; int sl[9], sc[9], sm[3][3]; for (i = 0; i < 9; i++) sl[i] = sc[i] = sm[i/3][i%3] = 0; for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { k = matriz[i][j]; k *= k; sl[i] += k; sc[j] += k; sm[i/3][j/3] += k; if (i == 8 && sc[j] != sum) break; } if (sl[i] != sum) break; } if(s == "") for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) if (sm[i][j] != sum) s = "NAO"; if(s == "") s = "SIM"; cnt++; cout << "Instancia " << cnt << endl << s << endl << endl; s = ""; } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks