Cod sursa(job #3159182)

Utilizator luc3lexaAlexandrescu Luca luc3lexa Data 20 octombrie 2023 20:58:29
Problema Jocul Flip Scor 20
Compilator cpp-64 Status done
Runda HLO 2023 - Cls 10 - Tema 0 Marime 0.91 kb
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
ifstream fin("flip.in");
ofstream fout("flip.out");
long int a[20][20];
int main()
{
    int n,m;
    fin >> n >> m;
    long long int s;
    for(int i = 1; i <=n; i++){
            s = 0;
        for(int j = 1; j <=m; j++){
            fin >> a[i][j];
            s+=a[i][j];
        };
        if(s < 0){
            for(int j = 1; j <=m; j++){
                a[i][j] = a[i][j]*-1;
            }
        }
    };
    for(int j = 1; j <=m; j++){
            s = 0;
        for(int i = 1; i <=n; i++){
            s+= a[i][j];
        };
        if(s < 0){
            for(int i = 1; i <=n; i++){
            a[i][j] = a[i][j]*-1;
        };
        }
    };
    long long int sfin = 0;
    for(int i = 1; i <=n; i++){
        for(int j = 1; j <=m; j++){
            sfin +=a[i][j];
        }
    };
    fout << sfin;
}