답안 #943356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
943356 2024-03-11T11:42:03 Z IUA_Hasin Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
505 ms 274432 KB
#include <bits/stdc++.h>
 
#define endl                                "\n"
#define finp                                for(int i=0; i<n; i++)
#define fknp                                for(int k=0; k<n; k++)
#define yeap                                cout<<"YES"<<endl
#define nope                                cout<<"NO"<<endl
#define inpintn                             int n; cin>>n
#define inpintarrn                          int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define inpllarrn                           long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define ll                                  long long
 
using namespace std;

int main ()
{   
    ll h, w;
    cin>>h>>w;
    ll brr[h][w];
    vector<pair<ll, ll>> v;
    for(int i=0; i<h; i++){
        string a;
        cin>>a;
        for(int j=0; j<w; j++){
            if(a[j]=='J'){
                brr[i][j] = 1;
                v.push_back({i, j});
            } else if(a[j]=='O'){
                brr[i][j] = 2;
            } else {
                brr[i][j] = 3;
            }
        }
    }

    ll orr[h][w];
    for(int i=0; i<h; i++){
        ll cnto = 0;
        for(int j=w-1; j>=0; j--){
            if(brr[i][j]==2){
                cnto++;
                orr[i][j] = cnto;
            } else {
                orr[i][j] = cnto;
            }
        }
    }

    ll irr[h][w];
    for(int i=0; i<w; i++){
        ll cnti = 0;
        for(int j=h-1; j>=0; j--){
            if(brr[j][i]==3){
                cnti++;
                irr[j][i] = cnti;
            } else {
                irr[j][i] = cnti;
            }
        }
    }

    ll siz = v.size();

    ll ans = 0;
    for(int i=0; i<siz; i++){   
        ll aa = v[i].first;
        ll bb = v[i].second;
        ll cc = (orr[aa][bb])*(irr[aa][bb]);
        ans = ans+cc;
    }
    cout<<ans<<endl;










    // for(int i=0; i<h; i++){
    //     for(int j=0; j<w; j++){
    //         cout << orr[i][j] << " ";
    //     }
    //     cout<<endl;
    // }

    // for(int i=0; i<h; i++){
    //     for(int j=0; j<w; j++){
    //         cout << irr[i][j] << " ";
    //     }
    //     cout<<endl;
    // }




    // ll siz = v.size();

    // for(int i=0; i<siz; i++){

    // }









    // cout<<endl;

    // for(int i=0; i<h; i++){
    //     for(int j=0; j<w; j++){
    //         cout << brr[i][j] << " ";
    //     }
    //     cout<<endl;
    // }
    
 
    return 0;
  
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 9 ms 6092 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 5 ms 4304 KB Output is correct
17 Correct 1 ms 392 KB Output is correct
18 Correct 12 ms 7880 KB Output is correct
19 Correct 8 ms 6612 KB Output is correct
20 Correct 9 ms 7628 KB Output is correct
21 Correct 11 ms 7756 KB Output is correct
22 Correct 9 ms 7680 KB Output is correct
23 Correct 9 ms 7628 KB Output is correct
24 Correct 12 ms 8040 KB Output is correct
25 Correct 8 ms 6608 KB Output is correct
26 Correct 9 ms 7628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 9 ms 6092 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 5 ms 4304 KB Output is correct
17 Correct 1 ms 392 KB Output is correct
18 Correct 12 ms 7880 KB Output is correct
19 Correct 8 ms 6612 KB Output is correct
20 Correct 9 ms 7628 KB Output is correct
21 Correct 11 ms 7756 KB Output is correct
22 Correct 9 ms 7680 KB Output is correct
23 Correct 9 ms 7628 KB Output is correct
24 Correct 12 ms 8040 KB Output is correct
25 Correct 8 ms 6608 KB Output is correct
26 Correct 9 ms 7628 KB Output is correct
27 Correct 467 ms 252996 KB Output is correct
28 Correct 2 ms 1236 KB Output is correct
29 Correct 23 ms 19908 KB Output is correct
30 Correct 2 ms 1112 KB Output is correct
31 Correct 328 ms 185804 KB Output is correct
32 Correct 406 ms 233752 KB Output is correct
33 Correct 433 ms 267044 KB Output is correct
34 Correct 386 ms 215960 KB Output is correct
35 Correct 429 ms 265120 KB Output is correct
36 Correct 436 ms 267608 KB Output is correct
37 Correct 505 ms 274432 KB Output is correct
38 Correct 307 ms 163920 KB Output is correct
39 Correct 292 ms 185104 KB Output is correct