Submission #880571

#TimeUsernameProblemLanguageResultExecution timeMemory
880571boris_7Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
495 ms59652 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; void solve(){ int n,m; cin>>n>>m; vector<string>v(n); for(string &i:v){ cin>>i; } vector<vector<int>>a(n); vector<vector<int>>b(m); for(int i = 0;i<n;i++){ for(int j = 0;j<m;j++){ if(v[i][j]=='O'){ a[i].push_back(j); } if(v[i][j]=='I'){ b[j].push_back(i); } } } ll ans = 0; for(int i = 0;i<n;i++){ for(int j= 0;j<m;j++){ if(v[i][j]=='J'){ ll c = a[i].end()-upper_bound(a[i].begin(),a[i].end(),j); ll d = b[j].end()-upper_bound(b[j].begin(),b[j].end(),i); ans+=c*d; } } } cout<<ans<<endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); // ll t;cin>>t;while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...