This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9)
#define INF (1e18)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
" : ("#__VA_ARGS__<<") = ";\
_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
freopen("D:\\input.in","r",stdin);
freopen("D:\\output.out","w",stdout);
freopen("D:\\error.out","w",stderr);
#endif
ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
cin.tie(0);
}
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
b%=MOD;
ll ans=1;
while(p>0){
if(p&1) ans=(ans*b)%MOD;
p/=2;
b=(b*b)%MOD;
}
return ans;
}
int32_t main() {
INIT();
//code...
int n,m; cin>>n>>m;
vector<string> g(n);
vector<vector<int>> h(n);
for(auto &i:g) cin>>i;
for(auto &i:h) i.resize(m);
For(j,0,m-1){
For(i,0,n-1){
if(g[i][j]=='#') h[i][j]=0;
else if(i==0) h[i][j]=1;
else h[i][j]=h[i-1][j]+1;
}
}
int ans=0;
For(i,0,n-1) For(j,0,m-1){
int now=INF;
Forr(k,j,0){
now=min(now,h[i][k]);
ans+=(now*(now+1)/2)*(j-k+1);
//cout<<i<<j<<k<<now<<"\n";
}
}
cout<<ans<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |