Submission #1258736

#TimeUsernameProblemLanguageResultExecution timeMemory
1258736hanguyenBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
164 ms150392 KiB
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int maxn = 3005;
int row[maxn][maxn] , col[maxn][maxn];
char a[maxn][maxn];
int n ,m;   

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (fopen(".inp", "r")) {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
    int res = 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 = n; i >= 1; i--) {
        for(int j = m; j >= 1; j--) {
            row[i][j] = row[i][j + 1] + (a[i][j] == 'O'); 
            col[i][j] = col[i + 1][j] + (a[i][j] == 'I');
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(a[i][j] == 'J') {
                res += row[i][j + 1] * col[i + 1][j];
            }
        }
    }
    cout << res;
}

Compilation message (stderr)

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