Submission #531022

#TimeUsernameProblemLanguageResultExecution timeMemory
531022buidangnguyen05Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
347 ms118500 KiB
/* input

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 5e3 + 10;
int d[N][N], r[N][N];
char s[N][N];

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	if (fopen("task.inp", "r")) {
		freopen("task.inp", "r", stdin);
		freopen("task.out", "w", stdout);
	}
	
	int m, n; cin >> m >> n;
	for (int i = 1; i <= m; ++i) for (int j = 1; j <= n; ++j) cin >> s[i][j];

	for (int i = 1; i <= m; ++i) for (int j = n; j; --j) r[i][j] = r[i][j + 1] + (s[i][j + 1] == 'O');
	for (int j = 1; j <= n; ++j) for (int i = m; i; --i) d[i][j] = d[i + 1][j] + (s[i + 1][j] == 'I');
		
	ll res = 0;
	for (int i = 1; i <= m; ++i) for (int j = 1; j <= n; ++j) if (s[i][j] == 'J') res += r[i][j] * d[i][j];

	cout << res << "\n";
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:16:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   freopen("task.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:17:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   freopen("task.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...