제출 #1342187

#제출 시각아이디문제언어결과실행 시간메모리
1342187NipphitchBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
110 ms9304 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long 
const int N=3005;

int n,m,cnt_k[N],cnt_l[N],ans;
char c[N][N];

// ลองเก็บแบบ vector แทน เพราะ เค้าต้องการแบบที่ i<k และ j<l 
// ไม่ก่อลองเก็บแบบย้อนกลับ n->1 และ m->1

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> c[i][j];
            //if(c[i][j]=='O') cnt_l[i]++;
            //else if(c[i][j]=='I') cnt_k[j]++;
        }
    }
    for(int i=n;i>=1;i--){
        for(int j=m;j>=1;j--){
            if(c[i][j]=='O') cnt_l[i]++;
            else if(c[i][j]=='I') cnt_k[j]++;
            else ans+=(cnt_l[i]*cnt_k[j]);
        }
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...