Submission #818662

#TimeUsernameProblemLanguageResultExecution timeMemory
818662vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
596 ms63064 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 3005; int N, M; char grid[MX][MX]; vector<int> v[MX], vv[MX]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> N >> M; for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) { cin >> grid[i][j]; if(grid[i][j] == 'O') { v[i].push_back(j); } if(grid[i][j] == 'I') { vv[j].push_back(i); } } } ll ans = 0; for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) { if(grid[i][j] != 'J') continue; auto x = lower_bound(v[i].begin(), v[i].end(), j) - v[i].begin(); auto y = lower_bound(vv[j].begin(), vv[j].end(), i) - vv[j].begin(); ans += 1LL * (v[i].size() - x) * (vv[j].size() - y); } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...