Submission #1352127

#TimeUsernameProblemLanguageResultExecution timeMemory
1352127nguthianmangcayBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
270 ms211816 KiB
#include<bits/stdc++.h>
using namespace std;
const int N=3e3+3;
const long long inf=1e18+3;
#define ll long long
#define fi first
#define se second
#define VOI void
#define int long long

int a[N][N];

ll cnt[2][N][N];

VOI jiangly(){

    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            char x;
            cin>>x;
            if(x == 'J'){
                a[i][j] = 1;
            }
            else if(x == 'O'){
                a[i][j] = 2;
            }
            else if(x == 'I'){
                a[i][j] = 3;
            }
        }
    }
    for(int i=h;i>=1;i--){
        for(int j=w;j>=1;j--){
            cnt[0][i][j] = cnt[0][i][j+1] + (a[i][j] == 2);
            cnt[1][j][i] = cnt[1][j][i+1] + (a[i][j] == 3);
        }
    }
    ll ans = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(a[i][j] == 1){
//                cout<<cnt[0][i][j+1]<<" "<<cnt[1][j][i+1]<<"\n";
                ans += (cnt[0][i][j+1] * cnt[1][j][i+1]);
            }
        }
    }
    cout<<ans;

}
int32_t main(){
    cin.tie(0)->sync_with_stdio(0);
    if(fopen("QUANSENSEI.inp","r")){
        freopen("O(0).inp","r",stdin);
    }

//    if(fopen("input.txt","r")){
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
//    }
    jiangly();

//    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Compilation message (stderr)

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