Submission #877607

# Submission time Handle Problem Language Result Execution time Memory
877607 2023-11-23T11:02:22 Z JakobZorz Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
181 ms 89712 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second

int w,h;
string arr[3000];
int numo[3000][3000];
int numi[3000][3000];

void solve(){
    cin>>w>>h;
    for(int x=0;x<w;x++){
        cin>>arr[x];
    }
    
    for(int x=0;x<w;x++){
        for(int y=h-1;y>=0;y--){
            if(y!=h-1)
                numo[x][y]=numo[x][y+1];
            if(arr[x][y]=='O')
                numo[x][y]++;
        }
    }
    
    for(int y=0;y<h;y++){
        for(int x=w-1;x>=0;x--){
            if(x!=w-1)
                numi[x][y]=numi[x+1][y];
            if(arr[x][y]=='I')
                numi[x][y]++;
        }
    }
    
    ll res=0;
    for(int x=0;x<w;x++){
        for(int y=0;y<h;y++){
            if(arr[x][y]=='J'){
                res+=(ll)numi[x][y]*numo[x][y];
                //cout<<res<<"\n";
            }
        }
    }
    
    cout<<res<<"\n";
}

int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("bank.in","r",stdin);freopen("bank.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}

/*
 
4 4
JJOO
JJOO
IIJO
IIIJ

3 4
JOIJ
JIOO
IIII
 
 */
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 1376 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 1340 KB Output is correct
12 Correct 1 ms 2904 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 1376 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 1340 KB Output is correct
12 Correct 1 ms 2904 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 5 ms 9560 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 6 ms 8796 KB Output is correct
19 Correct 4 ms 9820 KB Output is correct
20 Correct 4 ms 13404 KB Output is correct
21 Correct 5 ms 10076 KB Output is correct
22 Correct 4 ms 11324 KB Output is correct
23 Correct 4 ms 13392 KB Output is correct
24 Correct 5 ms 9816 KB Output is correct
25 Correct 4 ms 12096 KB Output is correct
26 Correct 4 ms 13348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 1376 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 1368 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 1340 KB Output is correct
12 Correct 1 ms 2904 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 5 ms 9560 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 3 ms 4700 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 6 ms 8796 KB Output is correct
19 Correct 4 ms 9820 KB Output is correct
20 Correct 4 ms 13404 KB Output is correct
21 Correct 5 ms 10076 KB Output is correct
22 Correct 4 ms 11324 KB Output is correct
23 Correct 4 ms 13392 KB Output is correct
24 Correct 5 ms 9816 KB Output is correct
25 Correct 4 ms 12096 KB Output is correct
26 Correct 4 ms 13348 KB Output is correct
27 Correct 171 ms 88404 KB Output is correct
28 Correct 7 ms 54876 KB Output is correct
29 Correct 7 ms 8764 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 111 ms 72108 KB Output is correct
32 Correct 163 ms 89712 KB Output is correct
33 Correct 137 ms 89172 KB Output is correct
34 Correct 156 ms 83436 KB Output is correct
35 Correct 136 ms 89424 KB Output is correct
36 Correct 138 ms 89224 KB Output is correct
37 Correct 181 ms 89704 KB Output is correct
38 Correct 90 ms 73556 KB Output is correct
39 Correct 80 ms 75088 KB Output is correct