Submission #197858

#TimeUsernameProblemLanguageResultExecution timeMemory
197858triplem5dsStrah (COCI18_strah)C++14
110 / 110
728 ms23892 KiB
#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; int getR(int l, int r){ return r * (r + 1) / 2 - l * (l - 1) /2; } 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){ vector<int> stk; stk.push_back(-1); f(j,0,m){ while(stk.size() > 1 && a[i][stk.back()] >= a[i][j])stk.pop_back(); stk.pb(j); int mn = INT_MAX; for(int k = stk.size()-1; k >= 1; --k){ sum += a[i][stk[k]] * (a[i][stk[k]] + 1) / 2 * getR(j-stk[k]+1,j-stk[k-1]); } } } cout << sum << '\n'; return 0; }

Compilation message (stderr)

strah.cpp: In function 'int32_t main()':
strah.cpp:49:11: warning: unused variable 'mn' [-Wunused-variable]
       int mn = INT_MAX;
           ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...