Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int vertical[105];
- int horizontal[105];
- int diagonal;
- bool numCheck[110];
- int main(){
- int n;
- scanf("%d",&n);
- for(int i = 0;i < n;++i){
- for(int a = 0;a < n;++a){
- int input;
- scanf("%d",&input);
- numCheck[input] = true;
- vertical[i] += input;
- horizontal[a] += input;
- if(i == a) diagonal += input;
- }
- }
- int baseValue = vertical[0];
- int bound = n * n;
- for(int i = 1;i <= bound;++i){
- if(numCheck[i] == false){
- printf("No");
- return 0;
- }
- }
- for(int i = 0;i < n;++i){
- if(vertical[i] != baseValue){
- printf("No");
- return 0;
- }
- else if(horizontal[i] != baseValue){
- printf("No");
- return 0;
- }
- }
- if(diagonal != baseValue) printf("No");
- else printf("Yes");
- return 0;
- }
Add Comment
Please, Sign In to add comment