Submission #914420

# Submission time Handle Problem Language Result Execution time Memory
914420 2024-01-22T05:42:42 Z ReLice Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
305 ms 158692 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool f=0;
    if (x>y){x=y;f=1;}
    return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool f=0;
    if (x<y){x=y;f=1;}
    return f;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
void solve(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    ll orb[n][m],ingot[n][m];
    char a[n][m];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)cin>>a[i][j];
        for(j=m-1;j>=0;j--)orb[i][j]=(j<m-1 ? orb[i][j+1] : 0ll)+(a[i][j]=='O' ? 1 : 0);
    }
    for(j=0;j<m;j++){
        for(i=n-1;i>=0;i--)ingot[i][j]=(i<n-1 ? ingot[i+1][j] : 0ll)+(a[i][j]=='I' ? 1 : 0);
    }
    ll ans=0;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(a[i][j]=='J')ans+=orb[i][j]*ingot[i][j];
        }
    }
    cout<<ans<<endl;
}

signed main(){
	start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
/*



*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 6 ms 3676 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 2732 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 6 ms 4700 KB Output is correct
19 Correct 5 ms 4444 KB Output is correct
20 Correct 6 ms 4768 KB Output is correct
21 Correct 6 ms 4700 KB Output is correct
22 Correct 7 ms 4440 KB Output is correct
23 Correct 6 ms 4700 KB Output is correct
24 Correct 7 ms 4700 KB Output is correct
25 Correct 6 ms 4560 KB Output is correct
26 Correct 6 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 6 ms 3676 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 2732 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 6 ms 4700 KB Output is correct
19 Correct 5 ms 4444 KB Output is correct
20 Correct 6 ms 4768 KB Output is correct
21 Correct 6 ms 4700 KB Output is correct
22 Correct 7 ms 4440 KB Output is correct
23 Correct 6 ms 4700 KB Output is correct
24 Correct 7 ms 4700 KB Output is correct
25 Correct 6 ms 4560 KB Output is correct
26 Correct 6 ms 4700 KB Output is correct
27 Correct 279 ms 149976 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Correct 15 ms 11848 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 199 ms 110500 KB Output is correct
32 Correct 275 ms 157816 KB Output is correct
33 Correct 278 ms 158288 KB Output is correct
34 Correct 233 ms 128080 KB Output is correct
35 Correct 278 ms 157852 KB Output is correct
36 Correct 288 ms 158284 KB Output is correct
37 Correct 305 ms 158692 KB Output is correct
38 Correct 193 ms 109652 KB Output is correct
39 Correct 184 ms 109908 KB Output is correct