Submission #460775

#TimeUsernameProblemLanguageResultExecution timeMemory
460775grtStrah (COCI18_strah)C++17
110 / 110
192 ms23892 KiB
#include <bits/stdc++.h> #define PB push_back #define ST first #define ND second #define _ ios_base::sync_with_stdio(0); cin.tie(0); //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; const int nax = 2010; int n, m; char t[nax][nax]; int up[nax][nax]; int main() {_ cin >> n >> m; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { cin >> t[i][j]; if(t[i][j] == '.') up[i][j] = up[i - 1][j] + 1; else up[i][j] = 0; } } ll ans = 0; for(int i = 1; i <= n; ++i) { vector<pi> S = {{-1, 0}}; for(int j = 1; j <= m; ++j) { while((int)S.size() > 0 && S.back().ST >= up[i][j]) { S.pop_back(); } S.emplace_back(up[i][j], j); //cout << i << " " << j << ": "; //for(auto x : S) { //cout << x.ST << " " << x.ND << ", "; //} //cout << "\n"; for(int k = (int)S.size() - 1; k > 0; --k) { int x = j - S[k].ND + 1; int y = j - S[k - 1].ND; ans += 1LL * (S[k].ST * (S[k].ST + 1)) / 2 * ((x + y) * (y - x + 1) / 2); } } } cout << ans; }
#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...