Submission #197855

# Submission time Handle Problem Language Result Execution time Memory
197855 2020-01-23T17:16:16 Z triplem5ds Strah (COCI18_strah) C++14
88 / 110
1000 ms 23004 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]);
        if(!mn)break;
        sum += mn * (mn + 1) / 2 * (k-j+1);
      }
    }

  }

  cout << sum << '\n';


  return 0;
}
# 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 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2524 KB Output is correct
2 Correct 17 ms 2608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2684 KB Output is correct
2 Correct 17 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2592 KB Output is correct
2 Correct 18 ms 2544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 9688 KB Output is correct
2 Correct 349 ms 17460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 294 ms 14984 KB Output is correct
2 Correct 533 ms 23004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 492 ms 10260 KB Output is correct
2 Correct 385 ms 18836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 12536 KB Output is correct
2 Execution timed out 1059 ms 20376 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1029 ms 21576 KB Time limit exceeded
2 Halted 0 ms 0 KB -