Submission #560297

# Submission time Handle Problem Language Result Execution time Memory
560297 2022-05-11T09:01:26 Z AGE Strah (COCI18_strah) C++14
44 / 110
241 ms 217796 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
const int N=1e5,M=305,mod=1e9+7;
int ok[M][M][M],prefix[M][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=-1;
            for(int k=0;k<n;k++){

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

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

            }

        }
    }


    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++)
            for(int k=0;k<n;k++)
                ans+=((k-prefix[k][i][j])*(ok[k][i][j]-k))*(j-i+1);

    cout<<ans<<endl;

    return 0;
}

Compilation message

strah.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 241 ms 217796 KB Output is correct
2 Correct 217 ms 217752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 217796 KB Output is correct
2 Correct 213 ms 217792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 217796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 2212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 2336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 2340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 3448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -