Submission #716191

# Submission time Handle Problem Language Result Execution time Memory
716191 2023-03-29T08:28:14 Z shoryu386 Bitaro the Brave (JOI19_ho_t1) C++17
50 / 100
197 ms 274432 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m; cin >> n >> m;
	char arr[n][m];
	for (int x = n-1; x > -1; x--){
		for (int y = 0; y < m; y++) cin >> arr[x][y];
	}
	
	int OpsumHori[n][m], OpsumVert[n][m], IpsumHori[n][m], IpsumVert[n][m];
	for (int x = 0; x < n; x++){
		OpsumHori[x][m-1] = (arr[x][m-1] == 'O');
		IpsumHori[x][m-1] = (arr[x][m-1] == 'I');
		for (int y = m-2; y > -1; y--){
			OpsumHori[x][y] = OpsumHori[x][y+1] + (arr[x][y] == 'O');
			IpsumHori[x][y] = IpsumHori[x][y+1] + (arr[x][y] == 'I');
		}
	}
	
	for (int y = 0; y < m; y++){
		OpsumVert[0][y] = (arr[0][y] == 'O');
		IpsumVert[0][y] = (arr[0][y] == 'I');
		for (int x = 1; x < n; x++){
			OpsumVert[x][y] = OpsumVert[x-1][y] + (arr[x][y] == 'O');
			IpsumVert[x][y] = IpsumVert[x-1][y] + (arr[x][y] == 'I');
		}
	}
	
	int ans = 0;
	for (int x = 0; x < n; x++){
		for (int y = 0; y < m; y++){
			if (arr[x][y] == 'J') ans += OpsumHori[x][y] * IpsumVert[x][y];
		}
	}
	
	cout << ans;
}

Compilation message

joi2019_ho_t1.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 7 ms 6484 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 4 ms 4436 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 9 ms 8276 KB Output is correct
19 Correct 10 ms 8056 KB Output is correct
20 Correct 8 ms 8148 KB Output is correct
21 Correct 10 ms 8276 KB Output is correct
22 Correct 8 ms 8060 KB Output is correct
23 Correct 9 ms 8224 KB Output is correct
24 Correct 12 ms 8276 KB Output is correct
25 Correct 8 ms 8020 KB Output is correct
26 Correct 10 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 7 ms 6484 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 4 ms 4436 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 9 ms 8276 KB Output is correct
19 Correct 10 ms 8056 KB Output is correct
20 Correct 8 ms 8148 KB Output is correct
21 Correct 10 ms 8276 KB Output is correct
22 Correct 8 ms 8060 KB Output is correct
23 Correct 9 ms 8224 KB Output is correct
24 Correct 12 ms 8276 KB Output is correct
25 Correct 8 ms 8020 KB Output is correct
26 Correct 10 ms 8148 KB Output is correct
27 Runtime error 197 ms 274432 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -