Submission #110679

#TimeUsernameProblemLanguageResultExecution timeMemory
110679Breno_XDBitaro the Brave (JOI19_ho_t1)C++14
50 / 100
1084 ms113108 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 3200;
int N,M;
long long ans;
int matriz[MAXN][MAXN];
int row[MAXN][MAXN], r;
int column[MAXN][MAXN], c;
char letra;

int main(){

    //Leitura
    scanf("%d%d", &N, &M);
    for(int i=1; i<=N; i++){
        for(int j=1; j<=M; j++){
            cin >> letra;
            if(letra=='J') matriz[i][j]=-1;
            if(letra=='I') matriz[i][j]=1;
            if(letra=='O') column[i][j]+=++c;
            else column[i][j]=c;
        }
        c=0;
    }

    for(int i=0; i<=M; i++){
        for(int j=N; j>=1; j--){
            if(matriz[j][i]==1) row[j][i]+=++r;
            else row[j][i]=r;
            column[j][i] = column[j][M]-column[j][i];
        }
        r=0;
    }

    /*
    cout << endl;
    for(int i=1; i<=N; i++){
        for(int j=1; j<=M; j++){
            cout << matriz[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;

    cout << endl;
    for(int i=1; i<=N; i++){
        for(int j=1; j<=M; j++){
            cout << row[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;

    cout << endl;
    for(int i=1; i<=N; i++){
        for(int j=1; j<=M; j++){
            cout << column[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    */

    for(int i=1; i<=N; i++)
        for(int j=1; j<=M; j++)
            if(matriz[i][j]==-1) ans+= column[i][j]*row[i][j];

    printf("%lld", ans);
    return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...