-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneps198.cpp
More file actions
41 lines (32 loc) · 787 Bytes
/
Copy pathneps198.cpp
File metadata and controls
41 lines (32 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Contest : Neps
* Problem : 198 - Quadrado Mágico 3x3
* Link : https://neps.academy/br/exercise/198
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int main() {
fastio
int n = 3;
int diagP = 0, diagS = 0, mat[n][n], lin[n] = {0}, col[n] = {0};
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> mat[i][j];
lin[i] += mat[i][j];
col[j] += mat[i][j];
if (i == j) diagP += mat[i][j];
if (i + j == n - 1) diagS += mat[i][j];
}
}
for (int i = 0; i < n; ++i) {
if (lin[i] != diagP || col[i] != diagP) {
cout << "NAO\n";
return 0;
}
}
if (diagS != diagP) cout << "NAO\n";
else cout << "SIM\n";
return 0;
}