Submission #104250

#TimeUsernameProblemLanguageResultExecution timeMemory
104250tincamateiBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
373 ms159096 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 3000;

char getch(FILE *fin) {
	char ch = fgetc(fin);
	while(!isalpha(ch))
		ch = fgetc(fin);
	return ch;
}

char matr[1+MAX_N+1][1+MAX_N+1];
long long sp[2][1+MAX_N+1][1+MAX_N+1];

int main() {
#ifdef HOME
	FILE *fin = fopen("input.in", "r");
	FILE *fout = fopen("output.out", "w");
#else
	FILE *fin = stdin;
	FILE *fout = stdout;
#endif

	int n, m;
	long long rez = 0LL;

	fscanf(fin, "%d%d", &n, &m);

	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			matr[i][j] = getch(fin);
	
	for(int i = 1; i <= n; ++i)
		for(int j = m; j > 0; --j) {
			sp[0][i][j] += sp[0][i][j + 1];
			sp[1][i][j] += sp[1][i - 1][j];
			switch(matr[i][j]) {
				case 'J':
					sp[1][i][j] += sp[0][i][j];
					break;
				case 'O':
					sp[0][i][j]++;
					break;
				case 'I':
					rez += sp[1][i][j];
					break;
			}
		}

	fprintf(fout, "%lld", rez);

	fclose(fin);
	fclose(fout);
	return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:29:8: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fin, "%d%d", &n, &m);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...