# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104250 | tincamatei | Bitaro the Brave (JOI19_ho_t1) | C++14 | 373 ms | 159096 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |