Submission #1258731

#TimeUsernameProblemLanguageResultExecution timeMemory
1258731ducki_16Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
319 ms150464 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define str string #define pii pair<long long, long long> #define vll vector<ll> #define endl '\n' const ll mun = 3005, mod = 1e9 + 7; ll n, m, k, q, ans = 0; char a[mun][mun]; ll row[mun], col[mun], precol[mun][mun], prerow[mun][mun]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (ll i = 0; i < mun; i++) { row[i] = 0; col[i] = 0; } for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { cin >> a[i][j]; } } for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { if (a[i][j] == '0') row[i] = row[i] + 1; else if (a[i][j] == 'I') col[j] = col[j] + 1; } } for (ll j = 1; j <= m; j++) { for (ll i = 1; i <= n; i++) { precol[i][j] = precol[i - 1][j] + (a[i][j] == 'I'); } } for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { prerow[i][j] = prerow[i][j - 1] + (a[i][j] == 'O'); } } for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { if (a[i][j] == 'J') { ans += (prerow[i][m] - prerow[i][j]) * (precol[n][j] - precol[i][j]); } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...