Submission #743422

#TimeUsernameProblemLanguageResultExecution timeMemory
743422mickey080929Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
702 ms88608 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

char a[3010][3010];
int c[3010][3010];
int r[3010][3010];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            scanf(" %c", &a[i][j]);
        }
    }
    for (int i=1; i<=n; i++) {
        for (int j=m; j>=1; j--) {
            c[i][j] = c[i][j+1] + (a[i][j] == 'O');
        }
    }
    for (int j=1; j<=m; j++) {
        for (int i=n; i>=1; i--) {
            r[i][j] = r[i+1][j] + (a[i][j] == 'I');
        }
    }
    ll ans = 0;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            if (a[i][j] != 'J') continue;
            ans += (ll)c[i][j] * r[i][j];
        }
    }
    printf("%lld", ans);
}

Compilation message (stderr)

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