Submission #1132303

#TimeUsernameProblemLanguageResultExecution timeMemory
1132303nuutsnoyntonBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
582 ms124324 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; vector < ll > O[3002], I[3002]; int main() { ll n, m, r, x, y, i, j,j1, o1, i1, p, cnt,s,next, ans, t, z; cin >> n >> m; string str; vector < pair < ll, ll > > J; for (i =1; i <= n; i ++) { cin >> str; str = "." + str; for (j = 1; j <= m; j ++) { if (str[j] == 'J') J.push_back({i, j}); if ( str[j] == 'O') O[i].push_back(j); if ( str[j] == 'I') I[j].push_back(i); } } ans =0; for ( pair< ll, ll > P : J) { x =P.first; y = P.second; s = upper_bound(O[x].begin(), O[x].end(), y) - O[x].begin(); s = O[x].size() - s; p = upper_bound(I[y].begin(), I[y].end(), x) - I[y].begin(); p = I[y].size() - p; ans = ans + (s * p); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...