Submission #335617

#TimeUsernameProblemLanguageResultExecution timeMemory
335617JoshcBitaro the Brave (JOI19_ho_t1)C++11
100 / 100
905 ms88704 KiB
#include <cstdio>
using namespace std;

char c[3002][3002];
int a[3002][3002], b[3002][3002];

int main() {
    int h, w;
    long long ans = 0;
    scanf("%d%d", &h, &w);
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) scanf(" %c", &c[i][j]);
        for (int j=w; j>0; j--) a[i][j] = a[i][j+1]+(c[i][j]=='O'); 
    }
    for (int j=1; j<=w; j++) {
        for (int i=h; i>0; i--) {
            b[i][j] = b[i+1][j]+(c[i][j]=='I');
            ans += (c[i][j]=='J')*a[i][j]*b[i][j];
        }
    }
    printf("%lld\n", ans);
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     scanf("%d%d", &h, &w);
      |     ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         for (int j=1; j<=w; j++) scanf(" %c", &c[i][j]);
      |                                  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...