Submission #155809

# Submission time Handle Problem Language Result Execution time Memory
155809 2019-09-30T16:13:21 Z Evirir Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
544 ms 159244 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 3005

ll hor[MAXN][MAXN];
ll ver[MAXN][MAXN];

int main()
{
	mset(hor,0); mset(ver,0);
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,m; cin>>n>>m;
	string arr[MAXN];
	forn(i,0,n) cin>>arr[i];
	
	for(int i=0;i<n;i++){
		for(int j=m-1;j>=0;j--){
			if(j<m-1) hor[i][j]+=hor[i][j+1];
			if(arr[i][j]=='O') hor[i][j]++;
		}
	}
	
	for(int j=0;j<m;j++){
		for(int i=n-1;i>=0;i--){
			if(i<n-1) ver[i][j]+=ver[i+1][j];
			if(arr[i][j]=='I') ver[i][j]++;
		}
	}
	
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(arr[i][j]!='J') continue;
			ans+=hor[i][j+1]*ver[i+1][j];
		}
	}
	
	cout<<ans<<'\n';
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 122 ms 141736 KB Output is correct
2 Correct 120 ms 141820 KB Output is correct
3 Correct 120 ms 141768 KB Output is correct
4 Correct 121 ms 141780 KB Output is correct
5 Correct 121 ms 141800 KB Output is correct
6 Correct 121 ms 141804 KB Output is correct
7 Correct 138 ms 141908 KB Output is correct
8 Correct 121 ms 141820 KB Output is correct
9 Correct 144 ms 141816 KB Output is correct
10 Correct 120 ms 141764 KB Output is correct
11 Correct 123 ms 141784 KB Output is correct
12 Correct 121 ms 141816 KB Output is correct
13 Correct 121 ms 141812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 141736 KB Output is correct
2 Correct 120 ms 141820 KB Output is correct
3 Correct 120 ms 141768 KB Output is correct
4 Correct 121 ms 141780 KB Output is correct
5 Correct 121 ms 141800 KB Output is correct
6 Correct 121 ms 141804 KB Output is correct
7 Correct 138 ms 141908 KB Output is correct
8 Correct 121 ms 141820 KB Output is correct
9 Correct 144 ms 141816 KB Output is correct
10 Correct 120 ms 141764 KB Output is correct
11 Correct 123 ms 141784 KB Output is correct
12 Correct 121 ms 141816 KB Output is correct
13 Correct 121 ms 141812 KB Output is correct
14 Correct 126 ms 142184 KB Output is correct
15 Correct 121 ms 141736 KB Output is correct
16 Correct 122 ms 142044 KB Output is correct
17 Correct 125 ms 141784 KB Output is correct
18 Correct 126 ms 142328 KB Output is correct
19 Correct 142 ms 142328 KB Output is correct
20 Correct 134 ms 142416 KB Output is correct
21 Correct 128 ms 142252 KB Output is correct
22 Correct 124 ms 142200 KB Output is correct
23 Correct 126 ms 142284 KB Output is correct
24 Correct 149 ms 142328 KB Output is correct
25 Correct 141 ms 142312 KB Output is correct
26 Correct 125 ms 142332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 141736 KB Output is correct
2 Correct 120 ms 141820 KB Output is correct
3 Correct 120 ms 141768 KB Output is correct
4 Correct 121 ms 141780 KB Output is correct
5 Correct 121 ms 141800 KB Output is correct
6 Correct 121 ms 141804 KB Output is correct
7 Correct 138 ms 141908 KB Output is correct
8 Correct 121 ms 141820 KB Output is correct
9 Correct 144 ms 141816 KB Output is correct
10 Correct 120 ms 141764 KB Output is correct
11 Correct 123 ms 141784 KB Output is correct
12 Correct 121 ms 141816 KB Output is correct
13 Correct 121 ms 141812 KB Output is correct
14 Correct 126 ms 142184 KB Output is correct
15 Correct 121 ms 141736 KB Output is correct
16 Correct 122 ms 142044 KB Output is correct
17 Correct 125 ms 141784 KB Output is correct
18 Correct 126 ms 142328 KB Output is correct
19 Correct 142 ms 142328 KB Output is correct
20 Correct 134 ms 142416 KB Output is correct
21 Correct 128 ms 142252 KB Output is correct
22 Correct 124 ms 142200 KB Output is correct
23 Correct 126 ms 142284 KB Output is correct
24 Correct 149 ms 142328 KB Output is correct
25 Correct 141 ms 142312 KB Output is correct
26 Correct 125 ms 142332 KB Output is correct
27 Correct 496 ms 158584 KB Output is correct
28 Correct 120 ms 141816 KB Output is correct
29 Correct 132 ms 143272 KB Output is correct
30 Correct 121 ms 141856 KB Output is correct
31 Correct 420 ms 154588 KB Output is correct
32 Correct 463 ms 159044 KB Output is correct
33 Correct 447 ms 159148 KB Output is correct
34 Correct 444 ms 156664 KB Output is correct
35 Correct 535 ms 159088 KB Output is correct
36 Correct 431 ms 159224 KB Output is correct
37 Correct 544 ms 159244 KB Output is correct
38 Correct 351 ms 154512 KB Output is correct
39 Correct 319 ms 154588 KB Output is correct