Submission #1093354

#TimeUsernameProblemLanguageResultExecution timeMemory
1093354ortsacBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
412 ms159316 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MAXN = 3010; int pfCol[MAXN][MAXN]; int pfRow[MAXN][MAXN]; char mat[MAXN][MAXN]; int32_t main() { //freopen("in", "r", stdin); int h, w; cin >> h >> w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> mat[i][j]; } } for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { pfRow[i][j] = pfRow[i][j - 1]; if (mat[i][j] == 'O') pfRow[i][j]++; } } for (int i = 1; i <= w; i++) { for (int j = 1; j <= h; j++) { pfCol[i][j] = pfCol[i][j - 1]; if (mat[j][i] == 'I') pfCol[i][j]++; // coluna i, row j } } int ans = 0; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (mat[i][j] == 'J') ans += ((pfRow[i][w] - pfRow[i][j - 1])*(pfCol[j][h] - pfCol[j][i - 1])); } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...