Submission #627556

# Submission time Handle Problem Language Result Execution time Memory
627556 2022-08-12T16:51:15 Z Farhan_HY Strah (COCI18_strah) C++14
44 / 110
1000 ms 35616 KB
#include <bits/stdc++.h>
#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++)
        for(int j = 1; j <= m; j++)
            dp[i][j] += dp[i][j - 1] + i;
    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:11:17: warning: overflow in conversion from 'double' to 'int' changes value from '8.0e+18' to '2147483647' [-Woverflow]
   11 | const int inf = 8e18;
      |                 ^~~~
strah.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3624 KB Output is correct
2 Correct 6 ms 3540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3540 KB Output is correct
2 Correct 6 ms 3628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 3540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 14548 KB Output is correct
2 Incorrect 128 ms 26508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 23684 KB Output is correct
2 Incorrect 212 ms 34376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 425 ms 15292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 17236 KB Output is correct
2 Execution timed out 1087 ms 32648 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 35616 KB Time limit exceeded
2 Halted 0 ms 0 KB -