답안 #527596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527596 2022-02-17T18:02:40 Z SlavicG Bitaro the Brave (JOI19_ho_t1) C++17
50 / 100
70 ms 14148 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

const int N = 2005;
char c[N][N];
ll a[N][N], b[N][N];
void solve() { 
    int n, m;
    cin >> n >> m;
    for(int i = 0;i < n; ++i) {
        for(int j = 0;j < m; ++j) {
            cin >> c[i][j];
        }
    }

    for(int i = 0;i < n; ++i) {
        for(int j = m - 1; j >= 0; --j) {
            a[i][j] = a[i][j + 1];
            if(c[i][j] == 'O') ++a[i][j];
        }
    }

    for(int i = 0;i < m; ++i) {
        for(int j = n - 1;j >= 0; --j) {
            b[i][j] = b[i][j + 1];
            if(c[j][i] == 'I') ++b[i][j];
        }
    }

    ll ans = 0;

    for(int i = 0;i < n; ++i) {
        for(int j = 0;j < m; ++j) {
            if(c[i][j] != 'J') continue;

            ans += a[i][j + 1] * b[j][i + 1]; 
        }
    } 
    cout << ans << "\n";
} 
 
int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1336 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1336 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
14 Correct 10 ms 8120 KB Output is correct
15 Correct 2 ms 2892 KB Output is correct
16 Correct 6 ms 5964 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 11 ms 9444 KB Output is correct
19 Correct 9 ms 9132 KB Output is correct
20 Correct 11 ms 9292 KB Output is correct
21 Correct 11 ms 9420 KB Output is correct
22 Correct 9 ms 9164 KB Output is correct
23 Correct 9 ms 9292 KB Output is correct
24 Correct 13 ms 9420 KB Output is correct
25 Correct 9 ms 9140 KB Output is correct
26 Correct 9 ms 9292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1336 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
14 Correct 10 ms 8120 KB Output is correct
15 Correct 2 ms 2892 KB Output is correct
16 Correct 6 ms 5964 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 11 ms 9444 KB Output is correct
19 Correct 9 ms 9132 KB Output is correct
20 Correct 11 ms 9292 KB Output is correct
21 Correct 11 ms 9420 KB Output is correct
22 Correct 9 ms 9164 KB Output is correct
23 Correct 9 ms 9292 KB Output is correct
24 Correct 13 ms 9420 KB Output is correct
25 Correct 9 ms 9140 KB Output is correct
26 Correct 9 ms 9292 KB Output is correct
27 Runtime error 70 ms 14148 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -