Submission #1047827

#TimeUsernameProblemLanguageResultExecution timeMemory
1047827manhlinh1501Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
113 ms88660 KiB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int MAXN = 3e3 + 5;

int N, M;
char a[MAXN][MAXN];
int cO[MAXN][MAXN];
int cI[MAXN][MAXN];

signed main() {
#define TASK "code"

    if (fopen(TASK ".inp", "r")) {
        freopen(TASK ".inp", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M; j++)
            cin >> a[i][j];
    }
    for(int i = 1; i <= N; i++) {
        int cnt = 0;
        for(int j = M; j >= 1; j--) {
            if(a[i][j] == 'O')
                cnt++;
            cO[i][j] = cnt;
        }
    }
    for(int j = 1; j <= M; j++) {
        int cnt = 0;
        for(int i = N; i >= 1; i--) {
            if(a[i][j] == 'I')
                cnt++;
            cI[i][j] = cnt;
        }
    }
    i64 ans = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M; j++) {
            if(a[i][j] == 'J')
                ans += 1LL * cO[i][j] * cI[i][j];
        }
    }
    cout << ans;
    return (0 ^ 0);
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...