Cod sursa(job #2955039)

Utilizator SG2021StancuGeorge SG2021 Data 15 decembrie 2022 23:17:42
Problema Jocul Flip Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <iostream>
#include <fstream>
typedef long long int ll;
#define forn(i,e) for(ll i = 0 ; i < e; i++)



using namespace std;
ifstream f("flip.in");
ofstream g("flip.out");
int main(){
    ll a , b ;
    f >> a >> b;
    ll mat[a][b];
    forn(i,a){
        forn(j,b){
            f >> mat[i][j];
        }
    }

    forn(i,a){
        ll s = 0;
        forn(j,b){
            s += mat[i][j];
        }
        if(max(s,-s)!=s){
            forn(j,b){
                mat[i][j]*=(-1);
            }
        }

    }

    forn(i,b){
        ll s = 0;
        forn(j,a){
            s += mat[j][i];
        }
        if(max(s,-s)!=s){
            forn(j,a){
                mat[j][i]*=(-1);
            }
        }
    }
    ll sfinal = 0;
    forn(i,a){
        forn(j,b){
            sfinal += mat[i][j];
        }
    }
    g << sfinal;


}