답안 #99732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99732 2019-03-06T10:52:42 Z Fasho Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
236 ms 80760 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i];
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,ar[N],sum;

int preo[3005][3005],prei[3005][3005],m;

char s[3005][3005];

int main()
{
	fast;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>s[i]+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			preo[i][j]+=preo[i][j-1],prei[i][j]+=prei[i-1][j];
			if(s[i][j]=='I')
				prei[i][j]++;
			if(s[i][j]=='O')
				preo[i][j]++;
		}
	// for(int i=1;i<=n;i++)
	// {
	// 	for(int j=1;j<=m;j++)
	// 		cout<<prei[i][j]<<sp;
	// 	cout<<endl;
	// }
	// cout<<endl;
	// for(int i=1;i<=n;i++)
	// {
	// 	for(int j=1;j<=m;j++)
	// 		cout<<preo[i][j]<<sp;
	// 	cout<<endl;
	// }
	// cout<<endl;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i][j]!='J')
				continue;
			int o=preo[i][m]-preo[i][j-1];
			int p=prei[n][j]-prei[i-1][j];
			// cout<<o<<sp<<p<<sp<<i<<sp<<j<<endl;
			sum+=o*p;
		}
	}
	cout<<sum;

}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:31:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   cin>>s[i]+1;
        ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 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 3 ms 512 KB Output is correct
5 Correct 4 ms 1536 KB Output is correct
6 Correct 4 ms 1536 KB Output is correct
7 Correct 3 ms 1408 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 4 ms 1536 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
11 Correct 3 ms 1536 KB Output is correct
12 Correct 4 ms 1536 KB Output is correct
13 Correct 3 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 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 3 ms 512 KB Output is correct
5 Correct 4 ms 1536 KB Output is correct
6 Correct 4 ms 1536 KB Output is correct
7 Correct 3 ms 1408 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 4 ms 1536 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
11 Correct 3 ms 1536 KB Output is correct
12 Correct 4 ms 1536 KB Output is correct
13 Correct 3 ms 1408 KB Output is correct
14 Correct 16 ms 7424 KB Output is correct
15 Correct 7 ms 4992 KB Output is correct
16 Correct 7 ms 4224 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 14 ms 7936 KB Output is correct
19 Correct 11 ms 7936 KB Output is correct
20 Correct 11 ms 7808 KB Output is correct
21 Correct 14 ms 8064 KB Output is correct
22 Correct 12 ms 7936 KB Output is correct
23 Correct 12 ms 7808 KB Output is correct
24 Correct 14 ms 7936 KB Output is correct
25 Correct 12 ms 7936 KB Output is correct
26 Correct 12 ms 7808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 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 3 ms 512 KB Output is correct
5 Correct 4 ms 1536 KB Output is correct
6 Correct 4 ms 1536 KB Output is correct
7 Correct 3 ms 1408 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 4 ms 1536 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
11 Correct 3 ms 1536 KB Output is correct
12 Correct 4 ms 1536 KB Output is correct
13 Correct 3 ms 1408 KB Output is correct
14 Correct 16 ms 7424 KB Output is correct
15 Correct 7 ms 4992 KB Output is correct
16 Correct 7 ms 4224 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 14 ms 7936 KB Output is correct
19 Correct 11 ms 7936 KB Output is correct
20 Correct 11 ms 7808 KB Output is correct
21 Correct 14 ms 8064 KB Output is correct
22 Correct 12 ms 7936 KB Output is correct
23 Correct 12 ms 7808 KB Output is correct
24 Correct 14 ms 7936 KB Output is correct
25 Correct 12 ms 7936 KB Output is correct
26 Correct 12 ms 7808 KB Output is correct
27 Correct 210 ms 80732 KB Output is correct
28 Correct 28 ms 25976 KB Output is correct
29 Correct 14 ms 7808 KB Output is correct
30 Correct 0 ms 640 KB Output is correct
31 Correct 163 ms 67448 KB Output is correct
32 Correct 150 ms 80760 KB Output is correct
33 Correct 140 ms 80364 KB Output is correct
34 Correct 182 ms 77916 KB Output is correct
35 Correct 137 ms 80604 KB Output is correct
36 Correct 131 ms 80380 KB Output is correct
37 Correct 236 ms 80616 KB Output is correct
38 Correct 112 ms 67448 KB Output is correct
39 Correct 108 ms 67088 KB Output is correct