Submission #716320

# Submission time Handle Problem Language Result Execution time Memory
716320 2023-03-29T16:28:12 Z Ahmed57 Strah (COCI18_strah) C++14
0 / 110
103 ms 8184 KB
#include <bits/stdc++.h>

using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    char arr[n][m];
    for(int i = 0;i<n;i++){
        string s;cin>>s;
        for(int j = 0;j<m;j++){
            arr[i][j] = s[j];
        }
    }
    int l[m] = {0},left[m],right[m];
    long long all = 0;
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            if(arr[i][j]=='.')l[j]++;
            else l[j] = 0;
        }
        stack<int> s;
        for(int j = 0;j<m;j++){
            while(!s.empty()&&l[s.top()]>=l[j]){
                s.pop();
            }
            if(s.empty())left[j] = -1;
            else left[j] = s.top();
            s.push(j);
        }
        while(!s.empty())s.pop();
        for(int j = m-1;j>=0;j--){
            while(!s.empty()&&l[s.top()]>l[j]){
                s.pop();
            }
            if(s.empty())right[j] = m;
            else right[j] = s.top();
            s.push(j);
        }
        for(int j = 0;j<m;j++){
            //cout<<left[j]<<" "<<right[j]<<"\n";
            long long ans = (l[j]*(l[j]+1))/2 , len = (right[j]-left[j])-1;
            ans*=(len*(len+1))/2;
            all+=ans;
        }
    }
    cout<<all<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Incorrect 3 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 2356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 5184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 3424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -