이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define se second
#define fi first
#define pii pair<int,int>
#define pll pair<long long, long long>
ll h,w,power=0;
vector<vector<char>> thingy;
pll os[3001][3001];
void solve(){
    memset(os,0,sizeof(os));
    cin >> h >> w;
    for(int i=0; i<h; i++){
        vector<char> bruh;
        for(int j=0; j<w; j++){
            char temp;
            cin >> temp;
            bruh.push_back(temp);
        }
        thingy.push_back(bruh);
    }
    for(int i=h-1; i>=0; i--){
        for(int j=w-1; j>=0; j--){
            if(thingy[i][j]=='I'){
                if(i==h-1){
                    os[i][j].fi=1;
                    os[i][j].se=0;
                }else{
                    os[i][j].fi=os[i+1][j].fi+1;
                    os[i][j].se=os[i][j+1].se;
                }
            }else if(thingy[i][j]=='O'){
                if(j==w-1){
                    os[i][j].se=1;
                    os[i][j].fi=0;
                }else{
                    os[i][j].se=os[i][j+1].se+1;
                    os[i][j].fi=os[i+1][j].fi;
                }
            }else{
                if(j==w-1){
                    os[i][j].se=0;
                }else{
                    os[i][j].se=os[i][j+1].se;
                }
                if(i==h-1){
                    os[i][j].fi=0;
                }else{
                    os[i][j].fi=os[i+1][j].fi;
                }
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(thingy[i][j]=='J'){
                power+= os[i][j].fi*os[i][j].se;
            }
        }
    }
    cout << power << endl;
    return;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |