Submission #560315

# Submission time Handle Problem Language Result Execution time Memory
560315 2022-05-11T09:24:20 Z AGE Strah (COCI18_strah) C++14
55 / 110
194 ms 217320 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define int long long
using namespace std;
const int N=1e5,M=305,mod=1e9+7;
int ok[M][M][M],prefix[M][M],okk[M][M];
string s[M];
main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0;i<n;i++)
        cin>>s[i];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){

            int okk=0;
            for(int k=j;k<m;k++){

                if(s[i][k]=='#')
                    okk=1;

                ok[i][j][k]=okk;

            }

        }
    }

    for(int i=0;i<m;i++){
        for(int j=i;j<m;j++){

            int last=n;
            for(int k=n-1;k>=0;k--){

                if(ok[k][i][j]==1)
                    last=k;

                ok[k][i][j]=last;

            }

        }
    }

    int ans=0;

    for(int i=0;i<m;i++)
        for(int j=i;j<m;j++)
            prefix[i][j]=-1;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){

            int okk=0;

            for(int k=j;k<m;k++){

                if(s[i][k]=='#')
                    okk=1;

                if(okk==1)
                    prefix[j][k]=i;
            }
        }

        for(int j=0;j<m;j++)
            for(int k=j;k<m;k++)
                ans+=((prefix[j][k]-i)*(i-ok[i][j][k])*(k-j+1));
    }

    cout<<ans<<endl;

    return 0;
}

Compilation message

strah.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 217292 KB Output is correct
2 Correct 153 ms 217268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 217220 KB Output is correct
2 Correct 160 ms 217196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 217108 KB Output is correct
2 Correct 150 ms 217320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 1556 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 1612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 1620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 584 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 2680 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -