█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 4393

Problema 0xe1 - Cuadrado mágico

  • Autor: tylfoy
  • Fecha: 2021-06-16 00:06:16 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.01 s 2 KBi
#2
Correcto
0.004 s 1 KBi
#3
Correcto
0.004 s 1 KBi
#4
Incorrecto
0.007 s 7 KBi
#5
Correcto
0.004 s 2 KBi
#6
Correcto
0.004 s 1 KBi
#7
Incorrecto
0.004 s 3 KBi
#8
Correcto
0.004 s 3 KBi
#9
Correcto
0.004 s 4 KBi
#10
Correcto
0.005 s 2 KBi
#11
Correcto
0.005 s 2 KBi
#12
Correcto
0.004 s 2 KBi
#13
Correcto
0.004 s 1 KBi
#14
Correcto
0.005 s 1 KBi
#15
Correcto
0.006 s 2 KBi
#16
Correcto
0.006 s 1 KBi
#17
Correcto
0.005 s 1 KBi
#18
Correcto
0.005 s 2 KBi
#19
Correcto
0.007 s 2 KBi
#20
Correcto
0.005 s 2 KBi
Puntos totales: 90 / 100

Código

#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define sz(x) ((int)x.size())
#define MPI  3.14159265358979323846
#define pb push_back
#define all(x) x.begin(), x.end()

void __print(int x) {cerr << x;}
void __print(ll x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef Debug
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif

void solve(){
  int n; cin>>n;
  vector<vector<int>>a(n, vector<int>(n));
  for(int i=0; i<n ;i++){
    for(int j=0; j<n; j++){
      cin>>a[i][j];
    }
  }
  int diagonal1, diagonal2;
  int col, row;
  diagonal1 = diagonal2 = col= row = 0;
  for(int i=0; i<n;i++){
    for(int j=0; j<n; j++){
      if(i==j){
        diagonal1 += a[i][j];
      }
      row+=a[i][j];
      col+=a[j][i];
      diagonal2+= a[n-j-1][i];
    }
  }
  row /= n;
  col /= n;
  diagonal2 /= n;
  if(diagonal1 == diagonal2 && row == col){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
 // cout<<diagonal1<<" "<<diagonal2/n<<" "<<row/n<<" "<<col/n<<endl;;
}

int main(){
  ios::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
  int T=1; 
//  cin>> T;
  while(T--){
    solve();
  }
  return 0;
}