Submission #444128

#TimeUsernameProblemLanguageResultExecution timeMemory
444128nonsensenonsense1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
142 ms88292 KiB
#include <cstdio>

const int N = 3001;
int h, w, o[N][N], in[N][N];
char s[N][N];

int main() 
{
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; ++i) scanf("%s", s[i]);
	long long ans = 0;
	for (int i = h - 1; i >= 0; --i) {
		for (int j = w - 1; j >= 0; --j) {
			o[i][j] = o[i][j + 1] + (s[i][j] == 'O');
			in[i][j] = in[i + 1][j] + (s[i][j] == 'I');
			if (s[i][j] == 'J') ans += o[i][j] * in[i][j];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d%d", &h, &w);
      |  ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:10:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  for (int i = 0; i < h; ++i) scanf("%s", s[i]);
      |                              ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...