답안 #116699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116699 2019-06-13T15:40:20 Z ZwariowanyMarcin Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
329 ms 113520 KB
// #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


#define pb push_back
#define ld long double
#define fi first
#define se second
#define ll long long
#define ss(x) (int) x.size()
#define mp make_pair
#define FOR(i, n) for(int i = 1; n >= i; ++i)

using namespace std;
using namespace __gnu_pbds;
const int nax = 5005;

int n, m;
string s[nax];
int dol[nax][nax], prawo[nax][nax];
ll ans = 0;

int main() {
	
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin >> n >> m;
	for(int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	
	for(int i = m - 1; 0 <= i; --i) {
		for(int j = 0; j < n; ++j) {
			prawo[j][i] = prawo[j][i + 1] + (s[j][i + 1] == 'O');
		}
	}
	for(int i = n - 1; 0 <= i; --i) {
		for(int j = 0; j < m; ++j) {
			dol[i][j] = dol[i + 1][j] + (s[i + 1][j] == 'I');
		}
	}
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			ans += (dol[i][j] * prawo[i][j] * (s[i][j] == 'J'));
		}
	}
	cout << ans;
	
	
	
	
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 3 ms 1408 KB Output is correct
6 Correct 3 ms 1408 KB Output is correct
7 Correct 3 ms 1280 KB Output is correct
8 Correct 3 ms 1456 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 2 ms 1280 KB Output is correct
11 Correct 3 ms 1408 KB Output is correct
12 Correct 3 ms 1408 KB Output is correct
13 Correct 3 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 3 ms 1408 KB Output is correct
6 Correct 3 ms 1408 KB Output is correct
7 Correct 3 ms 1280 KB Output is correct
8 Correct 3 ms 1456 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 2 ms 1280 KB Output is correct
11 Correct 3 ms 1408 KB Output is correct
12 Correct 3 ms 1408 KB Output is correct
13 Correct 3 ms 1280 KB Output is correct
14 Correct 8 ms 6400 KB Output is correct
15 Correct 5 ms 3968 KB Output is correct
16 Correct 5 ms 3840 KB Output is correct
17 Correct 2 ms 640 KB Output is correct
18 Correct 11 ms 7012 KB Output is correct
19 Correct 10 ms 6912 KB Output is correct
20 Correct 10 ms 6784 KB Output is correct
21 Correct 11 ms 6912 KB Output is correct
22 Correct 9 ms 6912 KB Output is correct
23 Correct 10 ms 6912 KB Output is correct
24 Correct 23 ms 7040 KB Output is correct
25 Correct 10 ms 6912 KB Output is correct
26 Correct 9 ms 6912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 3 ms 1408 KB Output is correct
6 Correct 3 ms 1408 KB Output is correct
7 Correct 3 ms 1280 KB Output is correct
8 Correct 3 ms 1456 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 2 ms 1280 KB Output is correct
11 Correct 3 ms 1408 KB Output is correct
12 Correct 3 ms 1408 KB Output is correct
13 Correct 3 ms 1280 KB Output is correct
14 Correct 8 ms 6400 KB Output is correct
15 Correct 5 ms 3968 KB Output is correct
16 Correct 5 ms 3840 KB Output is correct
17 Correct 2 ms 640 KB Output is correct
18 Correct 11 ms 7012 KB Output is correct
19 Correct 10 ms 6912 KB Output is correct
20 Correct 10 ms 6784 KB Output is correct
21 Correct 11 ms 6912 KB Output is correct
22 Correct 9 ms 6912 KB Output is correct
23 Correct 10 ms 6912 KB Output is correct
24 Correct 23 ms 7040 KB Output is correct
25 Correct 10 ms 6912 KB Output is correct
26 Correct 9 ms 6912 KB Output is correct
27 Correct 300 ms 108536 KB Output is correct
28 Correct 18 ms 19456 KB Output is correct
29 Correct 12 ms 8960 KB Output is correct
30 Correct 2 ms 768 KB Output is correct
31 Correct 221 ms 82196 KB Output is correct
32 Correct 329 ms 112940 KB Output is correct
33 Correct 319 ms 113044 KB Output is correct
34 Correct 256 ms 95352 KB Output is correct
35 Correct 311 ms 112804 KB Output is correct
36 Correct 305 ms 113144 KB Output is correct
37 Correct 317 ms 113520 KB Output is correct
38 Correct 202 ms 81656 KB Output is correct
39 Correct 214 ms 81912 KB Output is correct