답안 #553855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
553855 2022-04-27T07:50:47 Z AA_Surely Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
399 ms 159180 KB
#include <bits/stdc++.h>

#define FOR(i,x,n) 	for(int i=x; i<n; i++)
#define F0R(i,n) 	FOR(i,0,n)
#define ROF(i,x,n) 	for(int i=n-1; i>=x; i--)
#define R0F(i,n) 	ROF(i,0,n)

#define WTF 		cout << "WTF" << endl

#define IOS 		ios::sync_with_stdio(false); cin.tie(0)
#define F 			first
#define S	 		second
#define pb 			push_back

#define ALL(x) 		x.begin(), x.end()
#define RALL(x) 	x.rbegin(), x.rend()

using namespace std;
typedef long long 		LL;

typedef pair<int, int> 	PII;
typedef pair<LL, LL> 	PLL;

typedef vector<int> 	VI;
typedef vector<LL> 		VLL;
typedef vector<PII> 	VPII;
typedef vector<PLL> 	VPLL;

const int N = 3000 + 7;
const int ALPHA = 27;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int LOG = 22;

int n, m;
LL ups[N][N], rps[N][N];
char grid[N][N];

int main() {
    IOS;
    
    cin >> n >> m;
    F0R(i, n) F0R(j, m) cin >> grid[i][j];
    F0R(i, n) {
        rps[i][m - 1] = (grid[i][m - 1] == 'O');
        R0F(j, m - 1) rps[i][j] = rps[i][j + 1] + (grid[i][j] == 'O');
    }

    F0R(j, m) {
        ups[n - 1][j] = (grid[n - 1][j] == 'I');
        R0F(i, n - 1) ups[i][j] = ups[i + 1][j] + (grid[i][j] == 'I');
    }
    
    LL ans = 0;
    F0R(i, n) F0R(j, m) if (grid[i][j] == 'J') ans += ups[i][j] * rps[i][j];
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1488 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 2 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1488 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 2 ms 1364 KB Output is correct
14 Correct 8 ms 8916 KB Output is correct
15 Correct 2 ms 5064 KB Output is correct
16 Correct 5 ms 5328 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 9 ms 9944 KB Output is correct
19 Correct 9 ms 9832 KB Output is correct
20 Correct 9 ms 9772 KB Output is correct
21 Correct 9 ms 9940 KB Output is correct
22 Correct 8 ms 9812 KB Output is correct
23 Correct 9 ms 9768 KB Output is correct
24 Correct 10 ms 9940 KB Output is correct
25 Correct 8 ms 9812 KB Output is correct
26 Correct 10 ms 9788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1488 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 2 ms 1364 KB Output is correct
14 Correct 8 ms 8916 KB Output is correct
15 Correct 2 ms 5064 KB Output is correct
16 Correct 5 ms 5328 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 9 ms 9944 KB Output is correct
19 Correct 9 ms 9832 KB Output is correct
20 Correct 9 ms 9772 KB Output is correct
21 Correct 9 ms 9940 KB Output is correct
22 Correct 8 ms 9812 KB Output is correct
23 Correct 9 ms 9768 KB Output is correct
24 Correct 10 ms 9940 KB Output is correct
25 Correct 8 ms 9812 KB Output is correct
26 Correct 10 ms 9788 KB Output is correct
27 Correct 353 ms 158632 KB Output is correct
28 Correct 10 ms 26324 KB Output is correct
29 Correct 19 ms 13868 KB Output is correct
30 Correct 1 ms 720 KB Output is correct
31 Correct 276 ms 131572 KB Output is correct
32 Correct 352 ms 159180 KB Output is correct
33 Correct 341 ms 158580 KB Output is correct
34 Correct 308 ms 152396 KB Output is correct
35 Correct 342 ms 159096 KB Output is correct
36 Correct 379 ms 158672 KB Output is correct
37 Correct 399 ms 159180 KB Output is correct
38 Correct 251 ms 130764 KB Output is correct
39 Correct 249 ms 130940 KB Output is correct