Submission #213335

# Submission time Handle Problem Language Result Execution time Memory
213335 2020-03-25T15:41:31 Z anubhavdhar Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
331 ms 158840 KB
#include<bits/stdc++.h>

#define ll long long int
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(i=0;i<(n);i++)
#define FORe(i,n) for(i=1;i<=(n);i++)
#define FORr(i,a,b) for(i=(a);i<(b);i++)
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define ff first 
#define ss second
#define cd complex<double>
#define vcd vector<cd>
#define ldd long double
#define all(x) (x).begin(),(x).end()

using namespace std;

const short int __PRECISION = 10;

const ll MOD = 1e9+7;
const ll INF = 1e17 + 1101;
const ll LOGN = 17;
const ll MAXN = 2e5+5;
const ll ROOTN = 320;

const ldd PI = acos(-1);
const ldd EPS = 1e-7;

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll H,W,i,j,ans = 0;
	cin>>H>>W;
	char A[H][W];
	ll ingot[H][W],orb[H][W];
	FOR(i,H)
		FOR(j,W)
		{
			cin>>A[i][j];
			orb[i][j] = ingot[i][j] = 0;
		}
	for(i=H-1;i>=0;i--)
		for(j=W-1;j>=0;j--)
			if (A[i][j] == 'O')
			{
				ingot[i][j] = ((i == H-1) ? 0 : ingot[i+1][j]);
				orb[i][j] = 1 + ((j<W-1) ? orb[i][j+1] : 0);
			}
			else if (A[i][j] == 'I')
			{
				orb[i][j] = ((j == W-1) ? 0 : orb[i][j+1]);
				ingot[i][j] = 1 + ((i<H-1) ? ingot[i+1][j] : 0);
			}
			else
			{
				orb[i][j] = ((j == W-1) ? 0 : orb[i][j+1]);
				ingot[i][j] = ((i == H-1) ? 0 : ingot[i+1][j]);
			}
	FOR(i,H)
		FOR(j,W)
			if (A[i][j] == 'J')
				ans += orb[i][j]*ingot[i][j];
	cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 12 ms 3712 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 8 ms 2688 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 14 ms 4736 KB Output is correct
19 Correct 11 ms 4608 KB Output is correct
20 Correct 11 ms 4736 KB Output is correct
21 Correct 14 ms 4864 KB Output is correct
22 Correct 11 ms 4608 KB Output is correct
23 Correct 11 ms 4736 KB Output is correct
24 Correct 14 ms 4864 KB Output is correct
25 Correct 11 ms 4608 KB Output is correct
26 Correct 11 ms 4736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 12 ms 3712 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 8 ms 2688 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 14 ms 4736 KB Output is correct
19 Correct 11 ms 4608 KB Output is correct
20 Correct 11 ms 4736 KB Output is correct
21 Correct 14 ms 4864 KB Output is correct
22 Correct 11 ms 4608 KB Output is correct
23 Correct 11 ms 4736 KB Output is correct
24 Correct 14 ms 4864 KB Output is correct
25 Correct 11 ms 4608 KB Output is correct
26 Correct 11 ms 4736 KB Output is correct
27 Correct 300 ms 150008 KB Output is correct
28 Correct 5 ms 768 KB Output is correct
29 Correct 22 ms 11776 KB Output is correct
30 Correct 6 ms 768 KB Output is correct
31 Correct 222 ms 110456 KB Output is correct
32 Correct 233 ms 157816 KB Output is correct
33 Correct 234 ms 158328 KB Output is correct
34 Correct 263 ms 128120 KB Output is correct
35 Correct 241 ms 157816 KB Output is correct
36 Correct 234 ms 158328 KB Output is correct
37 Correct 331 ms 158840 KB Output is correct
38 Correct 164 ms 109560 KB Output is correct
39 Correct 161 ms 109944 KB Output is correct