# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
502873 |
2022-01-06T16:40:35 Z |
inksamurai |
Strah (COCI18_strah) |
C++17 |
|
168 ms |
63076 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define crep(i,x,n) for(ll i=x;i<n;i++)
#define drep(i,n) for(ll i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
void prll(){
cout<<"\n";
}
template<class te,class ...ti>
void prll(const te&v, const ti&...nv) {
cout<<v;
if(sizeof...(nv)){
cout<<" ";
prll(nv...);
}
}
using pii=pair<ll,ll>;
using vi=vector<ll>;
using vll=vector<long long>;
void slv(){
ll h,w;
cin>>h>>w;
vec(vi) a(h+1,vi(w));
rep(i,h){
rep(j,w){
char ch;
cin>>ch;
a[i][j]=(ch=='.');
}
}
h++;
vec(vi) dwn(h,vi(w));
drep(i,h){
rep(j,w){
if(!a[i][j]) dwn[i][j]=i;
else dwn[i][j]=dwn[i+1][j];
}
}
ll ans=0;
drep(i,h-1){
deque<tuple<ll,ll,ll>> dq;
ll _sum=0,_fsum=0;
drep(j,w){
if(dwn[i][j]==i){
dq.clear();
_sum=0;
_fsum=0;
}else{
ll lo=dwn[i][j],cnt=1;
while(sz(dq)){
auto [plo,pcnt,pj]=dq.front();
if(plo<lo){
break;
}
cnt+=pcnt;
_sum-=((plo-i)*(plo-i+1)/2)*pcnt;
_fsum-=((plo-i)*(plo-i+1)/2)*pcnt*(pj-j);
_fsum+=((lo-i)*(lo-i+1)/2)*pcnt*(pj-j);
dq.pop_front();
}
_sum+=((lo-i)*(lo-i+1)/2)*cnt;
_fsum+=_sum;
ans+=_fsum;
dq.push_front({lo,cnt,j});
}
}
}
prll(ans,'\n');
}
int main(){
_3qplfh5;
ll t=1;
// cin>>t;
rep(cs,t)
slv();
//
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1740 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1740 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1740 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1740 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
16732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
103 ms |
39008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
82 ms |
24692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
4556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
63076 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |