Submission #160524

#TimeUsernameProblemLanguageResultExecution timeMemory
160524dantoh000Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
904 ms158840 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int n,m;
    scanf("%lld%lld",&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("%lld ",ans);
}

Compilation message (stderr)

joi2019_ho_t1.cpp:4:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:10: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...