답안 #128503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128503 2019-07-11T04:26:35 Z qkxwsm Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
515 ms 114320 KB
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 3013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N, M;
int grid[MAXN][MAXN];
int so[MAXN][MAXN], si[MAXN][MAXN];
ll ans;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	FOR(i, 0, N)
	{
		string temps; cin >> temps;
		FOR(j, 0, M)
		{
			if (temps[j] == 'J') grid[i][j] = 0;
			if (temps[j] == 'O') grid[i][j] = 1;
			if (temps[j] == 'I') grid[i][j] = 2;
		}
	}
	FOR(i, 0, N)
	{
		FORD(j, M, 0)
		{
			so[i][j] = so[i][j + 1] + (grid[i][j] == 1);
		}
	}
	FOR(j, 0, M)
	{
		FORD(i, N, 0)
		{
			si[i][j] = si[i + 1][j] + (grid[i][j] == 2);
		}
	}
	FOR(i, 0, N)
	{
		FOR(j, 0, M)
		{
			if (grid[i][j] == 0) ans += so[i][j] * si[i][j];
		}
	}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 1656 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1656 KB Output is correct
9 Correct 3 ms 1656 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 4 ms 1656 KB Output is correct
12 Correct 3 ms 1656 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 1656 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1656 KB Output is correct
9 Correct 3 ms 1656 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 4 ms 1656 KB Output is correct
12 Correct 3 ms 1656 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
14 Correct 13 ms 8952 KB Output is correct
15 Correct 7 ms 5496 KB Output is correct
16 Correct 7 ms 5112 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 16 ms 9592 KB Output is correct
19 Correct 12 ms 9464 KB Output is correct
20 Correct 12 ms 9336 KB Output is correct
21 Correct 15 ms 9592 KB Output is correct
22 Correct 12 ms 9336 KB Output is correct
23 Correct 12 ms 9336 KB Output is correct
24 Correct 15 ms 9480 KB Output is correct
25 Correct 12 ms 9436 KB Output is correct
26 Correct 15 ms 9336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 1656 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1656 KB Output is correct
9 Correct 3 ms 1656 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 4 ms 1656 KB Output is correct
12 Correct 3 ms 1656 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
14 Correct 13 ms 8952 KB Output is correct
15 Correct 7 ms 5496 KB Output is correct
16 Correct 7 ms 5112 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 16 ms 9592 KB Output is correct
19 Correct 12 ms 9464 KB Output is correct
20 Correct 12 ms 9336 KB Output is correct
21 Correct 15 ms 9592 KB Output is correct
22 Correct 12 ms 9336 KB Output is correct
23 Correct 12 ms 9336 KB Output is correct
24 Correct 15 ms 9480 KB Output is correct
25 Correct 12 ms 9436 KB Output is correct
26 Correct 15 ms 9336 KB Output is correct
27 Correct 492 ms 114320 KB Output is correct
28 Correct 28 ms 28664 KB Output is correct
29 Correct 16 ms 10232 KB Output is correct
30 Correct 3 ms 760 KB Output is correct
31 Correct 365 ms 95052 KB Output is correct
32 Correct 432 ms 114080 KB Output is correct
33 Correct 413 ms 113656 KB Output is correct
34 Correct 431 ms 110200 KB Output is correct
35 Correct 455 ms 113864 KB Output is correct
36 Correct 410 ms 113400 KB Output is correct
37 Correct 515 ms 113984 KB Output is correct
38 Correct 300 ms 94968 KB Output is correct
39 Correct 300 ms 94584 KB Output is correct