Submission #1281259

#TimeUsernameProblemLanguageResultExecution timeMemory
1281259floBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
286 ms150344 KiB
#include <bits/stdc++.h>
#define task "testing"
#define int long long
#define multitest 0
using namespace std;

const int N = 3e3;

char c[N+5][N+5];

int row[N+5][N+5], col[N+5][N+5];

void flo(int ID) {
	int n, m; cin >> n >> m;
	
	for (int x = 1; x <= n; x++) {
		for (int y = 1; y <= m; y++) {
			cin >> c[x][y];
		}
	}
	
	for (int x = 1; x <= n; x++) {
		for (int y = m; y >= 1; y--) {
			row[x][y] = row[x][y+1]+(c[x][y] == 'O');
		}
	}
	
	for (int y = 1; y <= m; y++) {
		for (int x = n; x >= 1; x--) {
			col[x][y] = col[x+1][y]+(c[x][y] == 'I');
		}
	}
	
	int ans = 0;
	
	for (int x = 1; x <= n; x++) {
		for (int y = 1; y <= m; y++) {
			if (c[x][y] != 'J') continue;
			
			ans += row[x][y]*col[x][y];
		}
	}
	
	cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }

    int TCS = 1, ID = 1;

    if (multitest) {
        cin >> TCS;
    }

    while (TCS--) flo(ID++);

    return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...