Submission #1266313

#TimeUsernameProblemLanguageResultExecution timeMemory
1266313g4yuhgBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
321 ms150412 KiB
//Huyduocdithitp #include <bits/stdc++.h> typedef long long ll; #define pii pair<ll, ll> #define MP make_pair #define fi first #define se second #define TASK "connect" #define faster ios_base::sync_with_stdio(false);cin.tie(NULL); #define N 3005 #define LOG 18 #define endl '\n' using namespace std; ll h, w; char a[N][N]; ll pf1[N][N]; ll pf2[N][N]; signed main(void) { faster; cin >> h >> w; for (int i = 1; i <= h; i ++) { for (int j = 1; j <= w; j ++) { cin >> a[i][j]; } } for (int i = 1; i <= h; i ++) { for (int j = w; j >= 1; j --) { pf1[i][j] = pf1[i][j + 1]; if (a[i][j] == 'O') pf1[i][j] ++ ; } } for (int j = 1; j <= w; j ++) { for (int i = h; i >= 1; i --) { pf2[i][j] = pf2[i + 1][j]; if (a[i][j] == 'I') pf2[i][j] ++ ; } } ll ans = 0; for (int i = 1; i <= h; i ++) { for (int j = 1; j <= w; j ++) { if (a[i][j] == 'J') { ans += pf1[i][j] * pf2[i][j]; } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...