Submission #542089

# Submission time Handle Problem Language Result Execution time Memory
542089 2022-03-25T10:34:24 Z AJ00 Bitaro the Brave (JOI19_ho_t1) C++14
20 / 100
12 ms 9428 KB
#include <bits/stdc++.h>
using namespace std;
int sufr[3000][3000],sufc[3000][3000],val[3000][3000];
char ch;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1,n,m; 
   // cin >> t; 
    while (t--){
        cin >> n >> m;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                cin >> ch;
                if (ch == 'J'){
                    val[i][j] = 0;
                }
                if (ch == 'O'){
                    val[i][j] = 1;
                }
                if (ch == 'I'){
                    val[i][j] = 2;
                }
            }
        }
        // sufr[i][j] orbs in row i, after j
        // sufc[i][j] ingots in column j, after i
        for (int i = 0; i < n; i++){
            sufr[i][m-1] = (val[i][m-1] == 1);
            for (int j = m-2; j >= 0; j--){
                sufr[i][j] = sufr[i][j+1] + (val[i][j] == 1);
            }
        }
        for (int j = 0; j < m; j++){
            sufc[n-1][j] = (val[n-1][j] == 2);
            for (int i = n-2; i >= 0; i--){
                sufc[i][j] = sufc[i+1][j] + (val[i][j] == 2);
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                if (!val[i][j]){
                    ans += (sufr[i][j]*sufc[i][j]);
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1488 KB Output is correct
14 Correct 10 ms 8740 KB Output is correct
15 Correct 2 ms 5460 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 9428 KB Output is correct
19 Correct 9 ms 9264 KB Output is correct
20 Incorrect 7 ms 9172 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1488 KB Output is correct
14 Correct 10 ms 8740 KB Output is correct
15 Correct 2 ms 5460 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 9428 KB Output is correct
19 Correct 9 ms 9264 KB Output is correct
20 Incorrect 7 ms 9172 KB Output isn't correct
21 Halted 0 ms 0 KB -