Submission #627548

# Submission time Handle Problem Language Result Execution time Memory
627548 2022-08-12T16:42:19 Z Farhan_HY Strah (COCI18_strah) C++14
0 / 110
1000 ms 70860 KB
#include <bits/stdc++.h>
#define int long long
#define float double
#define pb push_back
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
/// Benzema is the best player in the world
const int inf = 8e18;
const int N = 2002;
const int M = 1e3 + 3;
const int LOG = 31;
const int mod = 1e9 + 7;
const float pi = atan(1) * 4;
int n, m, dp[N][N], suf[N][N];
string s[N];

void build()
{
    for(int i = 1; i <= n; i++)
        dp[i][1] = i;
    for(int j = 1; j <= m; j++)
        dp[1][j] = j;
    for(int i = 2; i <= n; i++)
        for(int j = 2; j <= m; j++)
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            dp[i][j] += dp[i][j - 1];
}

main()
{
    IOS
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> s[i], s[i] = '.' + s[i];
    build();
    for(int i = 1; i <= n; i++)
    {
        suf[i][m + 1] = m + 1;
        for(int j = m; j; j--)
        {
            suf[i][j] = suf[i][j + 1];
            if (s[i][j] == '#') suf[i][j] = j;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int k = i;
            int lst = m + 1;
            while(suf[k][j] != j && k <= n)
            {
                lst = min(lst, suf[k][j]);
                int y = lst - j;
                ans += dp[k - i + 1][y];
                k++;
            }
        }
    }
    cout << ans;
}
///use scanf

Compilation message

strah.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 4400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 25536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 46900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 496 ms 30184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 19688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 70860 KB Time limit exceeded
2 Halted 0 ms 0 KB -