Submission #128503

#TimeUsernameProblemLanguageResultExecution timeMemory
128503qkxwsmBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
515 ms114320 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() #define INF 1000000007 #define LLINF 2696969696969696969ll #define MAXN 3013 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N, M; int grid[MAXN][MAXN]; int so[MAXN][MAXN], si[MAXN][MAXN]; ll ans; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> M; FOR(i, 0, N) { string temps; cin >> temps; FOR(j, 0, M) { if (temps[j] == 'J') grid[i][j] = 0; if (temps[j] == 'O') grid[i][j] = 1; if (temps[j] == 'I') grid[i][j] = 2; } } FOR(i, 0, N) { FORD(j, M, 0) { so[i][j] = so[i][j + 1] + (grid[i][j] == 1); } } FOR(j, 0, M) { FORD(i, N, 0) { si[i][j] = si[i + 1][j] + (grid[i][j] == 2); } } FOR(i, 0, N) { FOR(j, 0, M) { if (grid[i][j] == 0) ans += so[i][j] * si[i][j]; } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...