Submission #914420

#TimeUsernameProblemLanguageResultExecution timeMemory
914420ReLiceBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
305 ms158692 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define vll vector<ll> #define bc back() #define arr array #define pll vector<pair<ll,ll>> using namespace std; template <class _T> bool chmin(_T &x, const _T &y){ bool f=0; if (x>y){x=y;f=1;} return f; } template <class _T> bool chmax(_T &x, const _T &y){ bool f=0; if (x<y){x=y;f=1;} return f; } //void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e18+7; const ll mod=1e9+7; const ll N=1e5+7; const ld eps=1e-9; void solve(){ ll i,j; ll n,m; cin>>n>>m; ll orb[n][m],ingot[n][m]; char a[n][m]; for(i=0;i<n;i++){ for(j=0;j<m;j++)cin>>a[i][j]; for(j=m-1;j>=0;j--)orb[i][j]=(j<m-1 ? orb[i][j+1] : 0ll)+(a[i][j]=='O' ? 1 : 0); } for(j=0;j<m;j++){ for(i=n-1;i>=0;i--)ingot[i][j]=(i<n-1 ? ingot[i+1][j] : 0ll)+(a[i][j]=='I' ? 1 : 0); } ll ans=0; for(i=0;i<n;i++){ for(j=0;j<m;j++){ if(a[i][j]=='J')ans+=orb[i][j]*ingot[i][j]; } } cout<<ans<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...