답안 #880571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880571 2023-11-29T16:35:54 Z boris_7 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
495 ms 59652 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;


void solve(){
    int n,m;
    cin>>n>>m;
    vector<string>v(n);
    for(string &i:v){
        cin>>i;
    }
    vector<vector<int>>a(n);
    vector<vector<int>>b(m);
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            if(v[i][j]=='O'){
                a[i].push_back(j);
            }
            if(v[i][j]=='I'){
                b[j].push_back(i);
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i<n;i++){
        for(int j= 0;j<m;j++){
            if(v[i][j]=='J'){
                ll c = a[i].end()-upper_bound(a[i].begin(),a[i].end(),j);
                ll d = b[j].end()-upper_bound(b[j].begin(),b[j].end(),i);
                ans+=c*d;
            }
        }
    }
    cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    // ll t;cin>>t;while(t--)
        solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 8 ms 1628 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 1116 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 11 ms 2140 KB Output is correct
19 Correct 3 ms 2140 KB Output is correct
20 Correct 3 ms 1628 KB Output is correct
21 Correct 10 ms 2152 KB Output is correct
22 Correct 5 ms 1628 KB Output is correct
23 Correct 3 ms 1628 KB Output is correct
24 Correct 11 ms 1832 KB Output is correct
25 Correct 3 ms 2140 KB Output is correct
26 Correct 3 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 8 ms 1628 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 1116 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 11 ms 2140 KB Output is correct
19 Correct 3 ms 2140 KB Output is correct
20 Correct 3 ms 1628 KB Output is correct
21 Correct 10 ms 2152 KB Output is correct
22 Correct 5 ms 1628 KB Output is correct
23 Correct 3 ms 1628 KB Output is correct
24 Correct 11 ms 1832 KB Output is correct
25 Correct 3 ms 2140 KB Output is correct
26 Correct 3 ms 1628 KB Output is correct
27 Correct 423 ms 45900 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 8 ms 4348 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 296 ms 32084 KB Output is correct
32 Correct 120 ms 59652 KB Output is correct
33 Correct 139 ms 47188 KB Output is correct
34 Correct 338 ms 35912 KB Output is correct
35 Correct 221 ms 48400 KB Output is correct
36 Correct 137 ms 47096 KB Output is correct
37 Correct 495 ms 53208 KB Output is correct
38 Correct 75 ms 40908 KB Output is correct
39 Correct 105 ms 37204 KB Output is correct