Submission #542087

# Submission time Handle Problem Language Result Execution time Memory
542087 2022-03-25T10:33:06 Z AJ00 Bitaro the Brave (JOI19_ho_t1) C++14
0 / 100
1 ms 340 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];
            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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -