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

Envío 1281

Problema 0xe1 - Cuadrado mágico

  • Autor: judavid.arias
  • Fecha: 2020-10-18 02:08:22 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#2
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#3
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#4
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#5
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#6
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#7
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#8
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#9
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#10
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#11
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#12
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#13
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#14
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#15
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#16
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#17
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#18
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#19
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
#20
Error de compilación
                      main.cpp:10:13: error: variable-sized object may not be initialized
        int square[n][n] = {};
                   ^
main.cpp:11:15: error: variable-sized object may not be initialized
        int solveRow[n]= {};
                     ^
main.cpp:12:18: error: variable-sized object may not be initialized
        int solveColunm[n]= {};
                        ^
main.cpp:27:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
        cout << d1 + " " +d2;
                ~~~^~~~~
main.cpp:27:13: note: use array indexing to silence this warning
1 warning and 3 errors generated.

                    
Puntos totales: 0 / 100

Código

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

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];
		}
	}
	
	cout << d1 + " " +d2;
	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;
	
	
}