Submission #1326523

#TimeUsernameProblemLanguageResultExecution timeMemory
1326523lunarechoBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
174 ms44680 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h, w; cin>>h>>w; vector<vector<char>> g(h, vector<char>(w)); vector<vector<int>> p(w, vector<int>(h, 0)); for(int i=0;i<h;++i) { for(int j=0;j<w;++j) { cin>>g[i][j]; p[j][i] += (i > 0 ? p[j][i - 1] : 0); p[j][i] += (g[i][j] == 'I'); } } ll cnt = 0; for(int i=0;i<h;++i) { vector<int> p2(w, 0); for(int j=w-1;j>=0;--j) { p2[j] += (j != w - 1 ? p2[j + 1] : 0); p2[j] += (g[i][j] == 'O'); if(g[i][j] == 'J') { ll x = p[j][h - 1] - p[j][i], y = p2[j]; cnt += (x * y); } } } cout<<cnt<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...