답안 #858862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858862 2023-10-09T09:40:58 Z StefanSebez Bitaro the Brave (JOI19_ho_t1) C++14
50 / 100
391 ms 274432 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
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;
		}
	}
	int pref[3][n+1][m+1];
	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]++;
		}
	}
	int res=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]!=0) continue;
			int x=pref[1][i][m]-pref[1][i-1][m]-pref[1][i][j]+pref[1][i-1][j];
			int 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 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 11 ms 6492 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 7 ms 4544 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 11 ms 8388 KB Output is correct
19 Correct 9 ms 8056 KB Output is correct
20 Correct 9 ms 8280 KB Output is correct
21 Correct 11 ms 8540 KB Output is correct
22 Correct 9 ms 8128 KB Output is correct
23 Correct 9 ms 8348 KB Output is correct
24 Correct 11 ms 8284 KB Output is correct
25 Correct 9 ms 8028 KB Output is correct
26 Correct 9 ms 8312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 11 ms 6492 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 7 ms 4544 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 11 ms 8388 KB Output is correct
19 Correct 9 ms 8056 KB Output is correct
20 Correct 9 ms 8280 KB Output is correct
21 Correct 11 ms 8540 KB Output is correct
22 Correct 9 ms 8128 KB Output is correct
23 Correct 9 ms 8348 KB Output is correct
24 Correct 11 ms 8284 KB Output is correct
25 Correct 9 ms 8028 KB Output is correct
26 Correct 9 ms 8312 KB Output is correct
27 Correct 391 ms 274432 KB Output is correct
28 Correct 1 ms 1112 KB Output is correct
29 Correct 28 ms 21340 KB Output is correct
30 Correct 2 ms 1112 KB Output is correct
31 Correct 278 ms 202532 KB Output is correct
32 Runtime error 270 ms 274432 KB Execution killed with signal 9
33 Halted 0 ms 0 KB -