Submission #85389

# Submission time Handle Problem Language Result Execution time Memory
85389 2018-11-19T15:16:20 Z DiegoGarcia Strah (COCI18_strah) C++11
22 / 110
1000 ms 38044 KB
#include <stdio.h>
#define ll long long
ll n,m,DP[2003][2003],sum,ans;
char mat[2003][2003];
int main()
{
    //(NM)^2 sirve para los primeros 55 pts
    scanf("%lld %lld",&n,&m);
    for( ll i=1; i<=n; i++ )
    {
        for( ll j=1; j<=m; j++ )
        {
            scanf(" %c",&mat[i][j]);
            DP[i][j] = DP[i-1][j] + DP[i][j-1] - DP[i-1][j-1] + ( mat[i][j] == '#' ? 0 : 1 );
        }
    }
    for( ll x1=1; x1<=n; x1++ ){
        for( ll y1=1; y1<=m; y1++ ){
            for( ll x2=x1; x2<=n; x2++ ){
                for( ll y2=y1; y2<=m; y2++ ){
                    sum = DP[x2][y2] - DP[x2][y1-1] - DP[x1-1][y2] + DP[x1-1][y1-1];
                    if( sum == (y2-y1+1)*(x2-x1+1) ) ans += (x2-x1+1)*(y2-y1+1);
                }
            }
        }
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

strah.cpp: In function 'int main()':
strah.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~~
strah.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c",&mat[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 456 KB Output is correct
2 Correct 2 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 3228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 3228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 3240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 14716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 25000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 25000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 25000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 38044 KB Time limit exceeded
2 Halted 0 ms 0 KB -