Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem: Sudoku Checker
- // Contest: Google Coding Competitions - Round B 2013 - Kick Start 2013
- // URL: https://codingcompetitions.withgoogle.com/kickstart/round/0000000000434ad7/00000000004347b3
- // Memory Limit: 1024 MB
- // Time Limit: 30000 ms
- // Date / Time: 2021-07-28 16:55:27
- // Author: cosenza
- // всё что ни делается - всё к лучшему
- //
- // Powered by CP Editor (https://cpeditor.org)
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int t;
- cin >> t;
- for(int k = 0; k < t; k++) {
- int n;
- cin >> n;
- set<int> dx[n * n], dy[n * n];
- int arr[n * n][n * n];
- bool foi = true;
- for(int i = 0; i < n * n; i++) {
- for(int j = 0; j < n * n; j++) {
- cin >> arr[i][j];
- if(dx[i].count(arr[i][j]) == 0 and arr[i][j] <= n * n and arr[i][j] > 0) {
- dx[i].insert(arr[i][j]);
- } else {
- foi = false;
- }
- if(dy[j].count(arr[i][j]) == 0 and arr[i][j] <= n * n and arr[i][j] > 0) {
- dy[j].insert(arr[i][j]);
- } else {
- foi = false;
- }
- }
- }
- cout << "Case #" << k + 1 << ": " << (foi ? "Yes\n" : "No\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement