답안 #705745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
705745 2023-03-05T05:25:05 Z myrcella Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
157 ms 115816 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const int maxn = 3030;

int n,m;
int grid[maxn][maxn];
int cnt[2][maxn][maxn];

int main() {
//	freopen("input.txt","r",stdin);	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m;
	rep(i,0,n) {
		string s;cin>>s;
		rep(j,0,m) {
			if (s[j]=='I') grid[i][j]=1;
			else if (s[j]=='J') grid[i][j] = 2;
		}
	}
	for (int i= n-1;i>=0;i--)
		for (int j = m-1;j>=0;j--) {
			cnt[0][i][j] = cnt[0][i][j+1] + (grid[i][j]==0);
			cnt[1][i][j] = cnt[1][i+1][j] + (grid[i][j]==1);
		}
	ll ans = 0;
	rep(i,0,n)
		rep(j,0,m) {
			if (grid[i][j]==2) ans += cnt[0][i][j] * cnt[1][i][j];
		}
	cout<<ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1600 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1600 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 7 ms 8688 KB Output is correct
15 Correct 3 ms 5456 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 8 ms 9552 KB Output is correct
19 Correct 6 ms 9116 KB Output is correct
20 Correct 6 ms 9040 KB Output is correct
21 Correct 8 ms 9556 KB Output is correct
22 Correct 6 ms 9168 KB Output is correct
23 Correct 5 ms 9044 KB Output is correct
24 Correct 9 ms 9428 KB Output is correct
25 Correct 5 ms 9044 KB Output is correct
26 Correct 5 ms 9044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1620 KB Output is correct
12 Correct 1 ms 1600 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 7 ms 8688 KB Output is correct
15 Correct 3 ms 5456 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 8 ms 9552 KB Output is correct
19 Correct 6 ms 9116 KB Output is correct
20 Correct 6 ms 9040 KB Output is correct
21 Correct 8 ms 9556 KB Output is correct
22 Correct 6 ms 9168 KB Output is correct
23 Correct 5 ms 9044 KB Output is correct
24 Correct 9 ms 9428 KB Output is correct
25 Correct 5 ms 9044 KB Output is correct
26 Correct 5 ms 9044 KB Output is correct
27 Correct 155 ms 115340 KB Output is correct
28 Correct 17 ms 28616 KB Output is correct
29 Correct 7 ms 9492 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 121 ms 95440 KB Output is correct
32 Correct 92 ms 111788 KB Output is correct
33 Correct 86 ms 112460 KB Output is correct
34 Correct 140 ms 110544 KB Output is correct
35 Correct 96 ms 112892 KB Output is correct
36 Correct 86 ms 112464 KB Output is correct
37 Correct 157 ms 115816 KB Output is correct
38 Correct 70 ms 89492 KB Output is correct
39 Correct 65 ms 90928 KB Output is correct