Submission #1310322

#TimeUsernameProblemLanguageResultExecution timeMemory
1310322syanvuBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
261 ms151240 KiB
// #pragma optimize ("g",on) // #pragma GCC optimize ("inline") // #pragma GCC optimize ("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC optimize ("03") #include <bits/stdc++.h> #define pb push_back #define SS ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr); #define int long long #define all(v) v.begin(),v.end() using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const int N = 201, inf = 1e9, mod = 998244353; void solve(){ int n, m; cin >> n >> m; string a[n]; for(int i = 0; i < n; i++){ cin >> a[i]; } int cnt1[n + 1][m + 1] = {}, cnt2[n + 1][m + 1] = {}; for(int i = 0; i < n; i++){ for(int j = m - 1; j >= 0; j--){ cnt1[i][j] = cnt1[i][j + 1] + (a[i][j] == 'O'); } } for(int j = 0; j < m; j++){ for(int i = n - 1; i >= 0; i--){ cnt2[i][j] = cnt2[i + 1][j] + (a[i][j] == 'I'); } } int ans = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(a[i][j] == 'J'){ ans += cnt1[i][j] * cnt2[i][j]; } } } cout << ans << '\n'; } signed main(){ SS // freopen("trains.in", "r", stdin); // freopen("trains.out", "w", stdout); int t = 1; // cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...