Submission #160523

#TimeUsernameProblemLanguageResultExecution timeMemory
160523dantoh000Bitaro the Brave (JOI19_ho_t1)C++14
20 / 100
20 ms2808 KiB
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    char grid[n][m];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            scanf(" %c",&grid[i][j]);
        }
    }
    int ct1[n][m];
    for (int j = 0; j < m; j++){
        ct1[n-1][j] = (grid[n-1][j]=='I');
        for (int i = n-2; i >= 0; i--){
            ct1[i][j] = ct1[i+1][j] + (grid[i][j]=='I');
        }
    }
    int ct2[n][m];
    for (int i = 0; i < n; i++){
        ct2[i][m-1] = (grid[i][m-1]=='O');
        for (int j = m-2; j >= 0; j--){
            ct2[i][j] = ct2[i][j+1] + (grid[i][j]=='O');
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (grid[i][j] == 'J') {
                ans += ct1[i][j]*ct2[i][j];
            }
        }
    }
    printf("%d ",ans);
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
joi2019_ho_t1.cpp:9:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c",&grid[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...