답안 #104250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104250 2019-04-04T12:11:15 Z tincamatei Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
373 ms 159096 KB
#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

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);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 5 ms 1536 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
8 Correct 4 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 4 ms 1408 KB Output is correct
11 Correct 5 ms 1740 KB Output is correct
12 Correct 5 ms 1536 KB Output is correct
13 Correct 4 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 5 ms 1536 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
8 Correct 4 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 4 ms 1408 KB Output is correct
11 Correct 5 ms 1740 KB Output is correct
12 Correct 5 ms 1536 KB Output is correct
13 Correct 4 ms 1408 KB Output is correct
14 Correct 17 ms 9036 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 11 ms 5376 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 17 ms 9984 KB Output is correct
19 Correct 17 ms 9856 KB Output is correct
20 Correct 19 ms 9848 KB Output is correct
21 Correct 19 ms 9984 KB Output is correct
22 Correct 19 ms 9856 KB Output is correct
23 Correct 20 ms 9848 KB Output is correct
24 Correct 21 ms 9980 KB Output is correct
25 Correct 19 ms 9856 KB Output is correct
26 Correct 16 ms 9760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 5 ms 1536 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
8 Correct 4 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 4 ms 1408 KB Output is correct
11 Correct 5 ms 1740 KB Output is correct
12 Correct 5 ms 1536 KB Output is correct
13 Correct 4 ms 1408 KB Output is correct
14 Correct 17 ms 9036 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 11 ms 5376 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 17 ms 9984 KB Output is correct
19 Correct 17 ms 9856 KB Output is correct
20 Correct 19 ms 9848 KB Output is correct
21 Correct 19 ms 9984 KB Output is correct
22 Correct 19 ms 9856 KB Output is correct
23 Correct 20 ms 9848 KB Output is correct
24 Correct 21 ms 9980 KB Output is correct
25 Correct 19 ms 9856 KB Output is correct
26 Correct 16 ms 9760 KB Output is correct
27 Correct 373 ms 158576 KB Output is correct
28 Correct 29 ms 26360 KB Output is correct
29 Correct 31 ms 13952 KB Output is correct
30 Correct 4 ms 896 KB Output is correct
31 Correct 269 ms 131324 KB Output is correct
32 Correct 301 ms 158996 KB Output is correct
33 Correct 311 ms 158396 KB Output is correct
34 Correct 346 ms 152312 KB Output is correct
35 Correct 322 ms 158980 KB Output is correct
36 Correct 318 ms 158456 KB Output is correct
37 Correct 318 ms 159096 KB Output is correct
38 Correct 261 ms 130780 KB Output is correct
39 Correct 201 ms 130808 KB Output is correct