Submission #441699

#TimeUsernameProblemLanguageResultExecution timeMemory
441699julian33Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
572 ms118280 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define FOR(i,j,n) for(int i=j;i<n;i++) #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} const int mxN=5e3+5; int psaO[mxN][mxN],psaI[mxN][mxN]; char grid[mxN][mxN]; int main(){ cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>grid[i][j]; if(grid[i][j]=='O') psaO[i][j]=1; else if(grid[i][j]=='I') psaI[j][i]=1; psaO[i][j]+=psaO[i][j-1]; psaI[j][i]+=psaI[j][i-1]; } } ll ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(grid[i][j]!='J') continue; ll Ocnt=psaO[i][m]-psaO[i][j]; ll Icnt=psaI[j][n]-psaI[j][i]; ans+=Ocnt*Icnt; } } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...