답안 #110350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110350 2019-05-10T17:54:45 Z sams Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
966 ms 151296 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 3e3+10;

int h, w;
char mat[maxn][maxn];
long long sumO[maxn][maxn], sumI[maxn][maxn];

int main()
{
	cin >> h >> w;

	for(int i = 1 ; i <= h ; ++i)
		for(int j = 1 ; j <= w; ++j)
			cin >> mat[i][j];

	// make a sum of eche O
	for(int i = 1 ; i <= h ; ++i)
	{
		for(int j = 1 ; j <= w; ++j)
		{
			sumO[i][j] = sumO[i][j - 1];
			if(mat[i][j] == 'O') 
				sumO[i][j]++;
		}
	}

	for(int i = 1 ; i <= w ; ++i)
	{
		for(int j = 1 ; j <= h; ++j)
		{
			sumI[j][i] = sumI[j - 1][i];
			if(mat[j][i] == 'I') 
				sumI[j][i]++;
		}
	}

	long long resp = 0;
	for(int i = 1 ; i <= h ; ++i)
	{
		for(int j = 1 ; j <= w; ++j)
		{	
			if(mat[i][j] == 'J')
			{

				long long O = sumO[i][w] - sumO[i][j];
				long long I = sumI[h][j] - sumI[i - 1][j];

				//cout <<  i << " " << j << " " << O << " " << I << "\n" ;
				resp += (O*I);
			}
		}
	}
	cout << resp << "\n";
	/*for(int i = 1 ; i <= h ; ++i)
	{
		for(int j = 1 ; j <= w; ++j)
		{
			cout << sumO[i][j] <<" ";
		}
		cout << "\n";
	}
		cout << "\n";

	for(int i = 1 ; i <= h ; ++i)
	{
		for(int j = 1 ; j <= w; ++j)
		{
			cout << sumI[i][j] <<" ";
		}
		cout << "\n";
	}*/
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 4 ms 1536 KB Output is correct
7 Correct 4 ms 1536 KB Output is correct
8 Correct 4 ms 1664 KB Output is correct
9 Correct 4 ms 1664 KB Output is correct
10 Correct 3 ms 1536 KB Output is correct
11 Correct 4 ms 1664 KB Output is correct
12 Correct 3 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 4 ms 1536 KB Output is correct
7 Correct 4 ms 1536 KB Output is correct
8 Correct 4 ms 1664 KB Output is correct
9 Correct 4 ms 1664 KB Output is correct
10 Correct 3 ms 1536 KB Output is correct
11 Correct 4 ms 1664 KB Output is correct
12 Correct 3 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 27 ms 8912 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 14 ms 5248 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 30 ms 9796 KB Output is correct
19 Correct 32 ms 9592 KB Output is correct
20 Correct 26 ms 9592 KB Output is correct
21 Correct 27 ms 10104 KB Output is correct
22 Correct 76 ms 9720 KB Output is correct
23 Correct 24 ms 9720 KB Output is correct
24 Correct 28 ms 9976 KB Output is correct
25 Correct 28 ms 9720 KB Output is correct
26 Correct 33 ms 9848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 4 ms 1536 KB Output is correct
7 Correct 4 ms 1536 KB Output is correct
8 Correct 4 ms 1664 KB Output is correct
9 Correct 4 ms 1664 KB Output is correct
10 Correct 3 ms 1536 KB Output is correct
11 Correct 4 ms 1664 KB Output is correct
12 Correct 3 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 27 ms 8912 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 14 ms 5248 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 30 ms 9796 KB Output is correct
19 Correct 32 ms 9592 KB Output is correct
20 Correct 26 ms 9592 KB Output is correct
21 Correct 27 ms 10104 KB Output is correct
22 Correct 76 ms 9720 KB Output is correct
23 Correct 24 ms 9720 KB Output is correct
24 Correct 28 ms 9976 KB Output is correct
25 Correct 28 ms 9720 KB Output is correct
26 Correct 33 ms 9848 KB Output is correct
27 Correct 949 ms 151296 KB Output is correct
28 Correct 26 ms 26360 KB Output is correct
29 Correct 66 ms 13816 KB Output is correct
30 Correct 5 ms 740 KB Output is correct
31 Correct 695 ms 126296 KB Output is correct
32 Correct 900 ms 151272 KB Output is correct
33 Correct 943 ms 150520 KB Output is correct
34 Correct 827 ms 146160 KB Output is correct
35 Correct 966 ms 151160 KB Output is correct
36 Correct 841 ms 150560 KB Output is correct
37 Correct 952 ms 151032 KB Output is correct
38 Correct 621 ms 125440 KB Output is correct
39 Correct 626 ms 125688 KB Output is correct