Submission #1258699

#TimeUsernameProblemLanguageResultExecution timeMemory
1258699trantien3771Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
166 ms150336 KiB
#include <bits/stdc++.h>
#define int long long
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;

using namespace std;

char a[3005][3005];
int pfo[3005][3005], pfi[3005][3005]; 

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    if (fopen(".INP", "r"))
    {       
        freopen(".INP", "r", stdin);
        freopen(".OUT", "w", stdout);
    }

    int h, w; cin >> h >> w;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }

    for (int i = h; i >= 1; i--){
        for (int j = w; j >= 1; j--){
            pfo[i][j] = pfo[i][j + 1] + (a[i][j] == 'O');
            pfi[i][j] = pfi[i + 1][j] + (a[i][j] == 'I');
            // cout << pfo[i][j] << " ";
        }
        // cout << '\n';
    }

    int cnt = 0;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            if (a[i][j] == 'J'){
                cnt += pfo[i][j + 1] * pfi[i + 1][j];
            }
        }
    }
    cout << cnt;

    return 0;
}

//TranTien

Compilation message (stderr)

joi2019_ho_t1.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main() {
      | ^~~~
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...