Submission #680537

# Submission time Handle Problem Language Result Execution time Memory
680537 2023-01-11T05:56:15 Z adilet_321 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
255 ms 154772 KB
#include <bits/stdc++.h>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#define ll long long
#define FOR(i,a) for (long long i=0;i<a;i++)
#define FORN(i,a) for (long long i=1;i<=a;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
using namespace std;
/*
ll bin1(ll a,ll b){
   if (b==0)return 1;
   if (b==1)return a;
   if (b&1)return bin(a,b-1)*a;
   c=bin(a,b/2);
   return c*c;
}
ll bin2(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1){
			res*=a;
		}
		a*=a;
		b/=2;
	}
	return res;
}
*/
vector <string> s;
ll ans=0;
ll a[3001][3001];
ll d[3003][3003];
void solve(){
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		string h;
		cin>>h;
		s.pb(h);
	}
	for(ll i=0;i<n;i++){
		ll h=0;
		for(ll j=0;j<m;j++){
			if (s[i][j]=='O'){
				h++;
			}
			a[i][j]=h;
		}
	}
	for(int i=0;i<m;i++){
		ll h=0;
		for (ll j=0;j<n;j++){
			if (s[j][i]=='I'){
				h++;
			}
			d[j][i]=h;
		}
	}
	for(ll i=0;i<n;i++){
		for (ll j=0;j<m;j++){
			if (s[i][j]=='J'){
				ans+=((a[i][m-1]-a[i][j])*(d[n-1][j]-d[i][j]));
			}
		}
	}
	cout<<ans;
}
int main(){
	//srand( time(0));
	//rand()
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
    ll c=1;
    while(c--){
    	solve();
	}
    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1232 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1236 KB Output is correct
12 Correct 1 ms 1232 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1232 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1236 KB Output is correct
12 Correct 1 ms 1232 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 6 ms 7764 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 3 ms 4672 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 6 ms 8788 KB Output is correct
19 Correct 5 ms 8532 KB Output is correct
20 Correct 6 ms 8532 KB Output is correct
21 Correct 7 ms 8764 KB Output is correct
22 Correct 6 ms 8660 KB Output is correct
23 Correct 6 ms 8532 KB Output is correct
24 Correct 6 ms 8784 KB Output is correct
25 Correct 6 ms 8532 KB Output is correct
26 Correct 5 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1232 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1236 KB Output is correct
12 Correct 1 ms 1232 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 6 ms 7764 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 3 ms 4672 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 6 ms 8788 KB Output is correct
19 Correct 5 ms 8532 KB Output is correct
20 Correct 6 ms 8532 KB Output is correct
21 Correct 7 ms 8764 KB Output is correct
22 Correct 6 ms 8660 KB Output is correct
23 Correct 6 ms 8532 KB Output is correct
24 Correct 6 ms 8784 KB Output is correct
25 Correct 6 ms 8532 KB Output is correct
26 Correct 5 ms 8536 KB Output is correct
27 Correct 247 ms 154288 KB Output is correct
28 Correct 9 ms 19664 KB Output is correct
29 Correct 12 ms 13756 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 168 ms 128560 KB Output is correct
32 Correct 244 ms 154624 KB Output is correct
33 Correct 224 ms 154196 KB Output is correct
34 Correct 207 ms 148352 KB Output is correct
35 Correct 224 ms 154696 KB Output is correct
36 Correct 211 ms 154420 KB Output is correct
37 Correct 255 ms 154772 KB Output is correct
38 Correct 154 ms 128016 KB Output is correct
39 Correct 152 ms 128064 KB Output is correct