답안 #858865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858865 2023-10-09T09:44:50 Z StefanSebez Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
271 ms 190044 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int pref[4][3050][3050];
signed main()
{
    int n,m;cin>>n>>m;
    int a[n+1][m+1];
    for(int i=1;i<=n;i++)
	{
		string s;cin>>s;
		for(int j=0;j<m;j++)
		{
			if(s[j]=='J') a[i][j+1]=0;
			if(s[j]=='O') a[i][j+1]=1;
			if(s[j]=='I') a[i][j+1]=2;
		}
	}
	memset(pref,0,sizeof(pref));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=0;k<=2;k++) pref[k][i][j]=pref[k][i-1][j]+pref[k][i][j-1]-pref[k][i-1][j-1];
			pref[a[i][j]][i][j]++;
		}
	}
	ll res=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]!=0) continue;
			ll x=pref[1][i][m]-pref[1][i-1][m]-pref[1][i][j]+pref[1][i-1][j];
			ll y=pref[2][n][j]-pref[2][n][j-1]-pref[2][i][j]+pref[2][i][j-1];
			res+=x*y;
		}
	}
	cout<<res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 146012 KB Output is correct
2 Correct 16 ms 145984 KB Output is correct
3 Correct 17 ms 146016 KB Output is correct
4 Correct 19 ms 146024 KB Output is correct
5 Correct 17 ms 146004 KB Output is correct
6 Correct 16 ms 146008 KB Output is correct
7 Correct 17 ms 146012 KB Output is correct
8 Correct 16 ms 146012 KB Output is correct
9 Correct 16 ms 146012 KB Output is correct
10 Correct 16 ms 146012 KB Output is correct
11 Correct 17 ms 145836 KB Output is correct
12 Correct 17 ms 146012 KB Output is correct
13 Correct 16 ms 146012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 146012 KB Output is correct
2 Correct 16 ms 145984 KB Output is correct
3 Correct 17 ms 146016 KB Output is correct
4 Correct 19 ms 146024 KB Output is correct
5 Correct 17 ms 146004 KB Output is correct
6 Correct 16 ms 146008 KB Output is correct
7 Correct 17 ms 146012 KB Output is correct
8 Correct 16 ms 146012 KB Output is correct
9 Correct 16 ms 146012 KB Output is correct
10 Correct 16 ms 146012 KB Output is correct
11 Correct 17 ms 145836 KB Output is correct
12 Correct 17 ms 146012 KB Output is correct
13 Correct 16 ms 146012 KB Output is correct
14 Correct 24 ms 146776 KB Output is correct
15 Correct 17 ms 146012 KB Output is correct
16 Correct 21 ms 146524 KB Output is correct
17 Correct 16 ms 146012 KB Output is correct
18 Correct 24 ms 147036 KB Output is correct
19 Correct 22 ms 146936 KB Output is correct
20 Correct 23 ms 146780 KB Output is correct
21 Correct 24 ms 146808 KB Output is correct
22 Correct 22 ms 146848 KB Output is correct
23 Correct 24 ms 147036 KB Output is correct
24 Correct 24 ms 146772 KB Output is correct
25 Correct 23 ms 146780 KB Output is correct
26 Correct 22 ms 146772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 146012 KB Output is correct
2 Correct 16 ms 145984 KB Output is correct
3 Correct 17 ms 146016 KB Output is correct
4 Correct 19 ms 146024 KB Output is correct
5 Correct 17 ms 146004 KB Output is correct
6 Correct 16 ms 146008 KB Output is correct
7 Correct 17 ms 146012 KB Output is correct
8 Correct 16 ms 146012 KB Output is correct
9 Correct 16 ms 146012 KB Output is correct
10 Correct 16 ms 146012 KB Output is correct
11 Correct 17 ms 145836 KB Output is correct
12 Correct 17 ms 146012 KB Output is correct
13 Correct 16 ms 146012 KB Output is correct
14 Correct 24 ms 146776 KB Output is correct
15 Correct 17 ms 146012 KB Output is correct
16 Correct 21 ms 146524 KB Output is correct
17 Correct 16 ms 146012 KB Output is correct
18 Correct 24 ms 147036 KB Output is correct
19 Correct 22 ms 146936 KB Output is correct
20 Correct 23 ms 146780 KB Output is correct
21 Correct 24 ms 146808 KB Output is correct
22 Correct 22 ms 146848 KB Output is correct
23 Correct 24 ms 147036 KB Output is correct
24 Correct 24 ms 146772 KB Output is correct
25 Correct 23 ms 146780 KB Output is correct
26 Correct 22 ms 146772 KB Output is correct
27 Correct 261 ms 179792 KB Output is correct
28 Correct 17 ms 146012 KB Output is correct
29 Correct 31 ms 148572 KB Output is correct
30 Correct 17 ms 146008 KB Output is correct
31 Correct 202 ms 170324 KB Output is correct
32 Correct 218 ms 189776 KB Output is correct
33 Correct 219 ms 189784 KB Output is correct
34 Correct 222 ms 181332 KB Output is correct
35 Correct 222 ms 190044 KB Output is correct
36 Correct 210 ms 189776 KB Output is correct
37 Correct 271 ms 190032 KB Output is correct
38 Correct 156 ms 176244 KB Output is correct
39 Correct 152 ms 176464 KB Output is correct