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

Envío 1282

Problema 0xe1 - Cuadrado mágico

  • Autor: judavid.arias
  • Fecha: 2020-10-18 02:10:21 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#2
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#3
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#4
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#5
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#6
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#7
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#8
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#9
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#10
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#11
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#12
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#13
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#14
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#15
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#16
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#17
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#18
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#19
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
#20
Error de compilación
                      main.cpp:9:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:10:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:11:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
3 errors generated.

                    
Puntos totales: 0 / 100

Código

#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int square[n][n] = {};
	int solveRow[n]= {};
	int solveColunm[n]= {};
	int d1 = 0;
	int d2 = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin >> square[i][j];
			solveRow[i] += square[i][j];
			solveColunm[j] += square[i][j];
			if(i == j)d1 += square[i][j];
			if(i == (n-1-j))d2 += square[i][j];
		}
	}
	
	if(d1 != d2)
	{
		cout <<  "NO";
		return 0;
	}
	
	
	bool rows = true;
	for(int i=0;i<n-1;i++)
	{
		rows = rows && solveRow[i] == solveRow[i+1] && solveColunm[i] == solveColunm[i+1];
		if(!rows)break;
	}
	
	if(!rows)
	{
		cout <<  "NO";
		return 0;
	}
	
	cout <<  "YES";	
	return 0;
	
	
}