Advertisement
cosenza987

Untitled

Jul 28th, 2021
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. // Problem: Sudoku Checker
  2. // Contest: Google Coding Competitions - Round B 2013 - Kick Start 2013
  3. // URL: https://codingcompetitions.withgoogle.com/kickstart/round/0000000000434ad7/00000000004347b3
  4. // Memory Limit: 1024 MB
  5. // Time Limit: 30000 ms
  6. // Date / Time: 2021-07-28 16:55:27
  7. // Author: cosenza
  8. // всё что ни делается - всё к лучшему
  9. //
  10. // Powered by CP Editor (https://cpeditor.org)
  11.  
  12. #include <bits/stdc++.h>
  13.  
  14. using namespace std;
  15.  
  16. int main() {
  17.     ios_base::sync_with_stdio(false);
  18.     cin.tie(0);
  19.     int t;
  20.     cin >> t;
  21.     for(int k = 0; k < t; k++) {
  22.         int n;
  23.         cin >> n;
  24.         set<int> dx[n * n], dy[n * n];
  25.         int arr[n * n][n * n];
  26.         bool foi = true;
  27.         for(int i = 0; i < n * n; i++) {
  28.             for(int j = 0; j < n * n; j++) {
  29.                 cin >> arr[i][j];
  30.                 if(dx[i].count(arr[i][j]) == 0 and arr[i][j] <= n * n and arr[i][j] > 0) {
  31.                     dx[i].insert(arr[i][j]);
  32.                 } else {
  33.                     foi = false;
  34.                 }
  35.                 if(dy[j].count(arr[i][j]) == 0 and arr[i][j] <= n * n and arr[i][j] > 0) {
  36.                     dy[j].insert(arr[i][j]);
  37.                 } else {
  38.                     foi = false;
  39.                 }
  40.             }
  41.         }
  42.         cout << "Case #" << k + 1 << ": " << (foi ? "Yes\n" : "No\n");
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement