Submission #197854

# Submission time Handle Problem Language Result Execution time Memory
197854 2020-01-23T17:15:15 Z triplem5ds Strah (COCI18_strah) C++14
55 / 110
1000 ms 23960 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =320;
const long double EPS = 1e-7;
char g[2005][2005];
int a[2005][2005];
int n, m;
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> n >> m;

  f(i,0,n)
    f(j,0,m)
      cin >> g[i][j];

  for(int i = n - 1; i >= 0; --i){
    f(j,0,m){
      if(g[i][j] == '.')a[i][j] = a[i+1][j] + 1;
    }
  }
  ll sum = 0;
  f(i,0,n){
    stack<int> stk;
    f(j,0,m){
      int mn = INT_MAX;
      f(k,j,m){
        mn = min(mn, a[i][k]);
        sum += mn * (mn + 1) / 2 * (k-j+1);
      }
    }

  }

  cout << sum << '\n';


  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 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 41 ms 2596 KB Output is correct
2 Correct 40 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 2528 KB Output is correct
2 Correct 41 ms 2556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 2808 KB Output is correct
2 Correct 46 ms 2612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 9564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 15776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 10144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 12408 KB Output is correct
2 Execution timed out 1082 ms 21752 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1028 ms 23960 KB Time limit exceeded
2 Halted 0 ms 0 KB -