Submission #165981

# Submission time Handle Problem Language Result Execution time Memory
165981 2019-11-30T01:51:41 Z socho Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
741 ms 161656 KB
#include "bits/stdc++.h"
using namespace std;

int main() {
    
    int h, w;
    cin >> h >> w;
    
    string arr[h];
    for (int i=0; i<h; i++) cin >> arr[i];
    
    long long iron[h+1][w+1], orbs[h+1][w+1];
    for (int i=0; i<h+1; i++) iron[i][0] = 0, orbs[i][0] = 0;
    for (int i=0; i<w+1; i++) iron[0][i] = 0, orbs[0][i] = 0;
    
    for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			if (arr[i][j] == 'I') iron[i+1][j+1] = iron[i][j+1] + 1;
			else iron[i+1][j+1] = iron[i][j+1];
			if (arr[i][j] == 'O') orbs[i+1][j+1] = orbs[i+1][j] + 1;
			else orbs[i+1][j+1] = orbs[i+1][j];
		}
	}
	
	long long score = 0;
	long long ik, jk;
	
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			if (arr[i][j] == 'J') {
				// cout << "POS: " << i << ' ' << j << endl;
				ik = i + 1;
				jk = j + 1;
				long long ot = iron[h][jk] - iron[ik][jk];
				long long at = orbs[ik][w] - orbs[ik][jk];
				score += (ot * at);
			}
		}
	}
	
	cout << score << endl;
    
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 508 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 508 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 18 ms 3832 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 12 ms 2808 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 23 ms 5064 KB Output is correct
19 Correct 20 ms 4600 KB Output is correct
20 Correct 21 ms 4856 KB Output is correct
21 Correct 23 ms 4984 KB Output is correct
22 Correct 19 ms 4600 KB Output is correct
23 Correct 20 ms 4856 KB Output is correct
24 Correct 23 ms 4984 KB Output is correct
25 Correct 20 ms 4600 KB Output is correct
26 Correct 20 ms 4856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 508 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 18 ms 3832 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 12 ms 2808 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 23 ms 5064 KB Output is correct
19 Correct 20 ms 4600 KB Output is correct
20 Correct 21 ms 4856 KB Output is correct
21 Correct 23 ms 4984 KB Output is correct
22 Correct 19 ms 4600 KB Output is correct
23 Correct 20 ms 4856 KB Output is correct
24 Correct 23 ms 4984 KB Output is correct
25 Correct 20 ms 4600 KB Output is correct
26 Correct 20 ms 4856 KB Output is correct
27 Correct 707 ms 153256 KB Output is correct
28 Correct 5 ms 888 KB Output is correct
29 Correct 51 ms 12152 KB Output is correct
30 Correct 4 ms 760 KB Output is correct
31 Correct 518 ms 114040 KB Output is correct
32 Correct 667 ms 160636 KB Output is correct
33 Correct 658 ms 161096 KB Output is correct
34 Correct 603 ms 131964 KB Output is correct
35 Correct 670 ms 160612 KB Output is correct
36 Correct 658 ms 161016 KB Output is correct
37 Correct 741 ms 161656 KB Output is correct
38 Correct 466 ms 113200 KB Output is correct
39 Correct 456 ms 113412 KB Output is correct