Submission #207833

#TimeUsernameProblemLanguageResultExecution timeMemory
207833pavementBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
880 ms92536 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, M, T;
char F[3005][3005];
vector<int> O[3005], I[3005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++) {
			cin >> F[i][j];
			if (F[i][j] == 'O') O[i].push_back(j);
			else if (F[i][j] == 'I') I[j].push_back(i);
		}
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++)
			if (F[i][j] == 'J') {
				auto it = upper_bound(O[i].begin(), O[i].end(), j), it2 = upper_bound(I[j].begin(), I[j].end(), i);
				T += (O[i].end() - it) * (I[j].end() - it2);
			}
	cout << T << '\n';
}

Compilation message (stderr)

joi2019_ho_t1.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...