Submission #418209

#TimeUsernameProblemLanguageResultExecution timeMemory
418209_Avocado_Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
216 ms159236 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; #define int int64_t signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin>>n>>m; vector<string>v; vector<vector<int>>orb(n+1, vector<int>(m+1)); vector<vector<int>>ing(n+1, vector<int>(m+1)); for(int i = 1; i<=n; ++i){ string a; cin>>a; v.push_back(a); for(int j = 1; j<=m; ++j){ char c = a[j-1]; if(c == 'O') orb[i][j] = 1 + orb[i][j-1]; if(c == 'I') ing[i][j] = 1 + ing[i-1][j]; if(!orb[i][j]) orb[i][j] = orb[i][j-1]; if(!ing[i][j]) ing[i][j] = ing[i-1][j]; } } /* for(auto u: orb){ for(auto v: u) cout<<v<<" "; cout<<endl; } cout<<endl; for(auto u: ing){ for(auto v: u) cout<<v<<" "; cout<<endl; } cout<<endl; */ int ans = 0; for(int i = 1; i<=n; ++i){ for(int j = 1; j<=m; ++j){ int o = orb[i][m]; int in = ing[n][j]; if(v[i-1][j-1] == 'J') ans += (o-orb[i][j]) * (in - ing[i][j]); } } cout<<ans; cout<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...