Submission #818757

#TimeUsernameProblemLanguageResultExecution timeMemory
818757vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
617 ms108016 KiB
#include <bits/stdc++.h> #define ll long long #define pll pair<int, int> #define pb push_back #define fi first #define se second using namespace std; const int MX=3005; int h, w, prefr[MX][MX], prefc[MX][MX]; ll ans; char g[MX][MX]; int main(){ cin >> h >> w; vector<pll> start; for(int i=1; i<=h; i++){ for(int j=1; j<=w; j++){ cin >> g[i][j]; if(g[i][j]=='J') start.pb({i, j}); prefr[i][j]=prefr[i][j-1]; prefc[j][i]=prefc[j][i-1]; if(g[i][j]=='O') prefr[i][j]++; if(g[i][j]=='I') prefc[j][i]++; } } for(auto i : start){ int r=i.fi, c=i.se; // cout << r << " " << c << endl; int oo=(prefr[r][w]-prefr[r][c]); int ii=(prefc[c][h]-prefc[c][r]); // cout << "nilai " << ii << " " << oo << endl; ans+=ii*oo; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...