# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
197858 |
2020-01-23T17:25:41 Z |
triplem5ds |
Strah (COCI18_strah) |
C++14 |
|
728 ms |
23892 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;
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
strah.cpp: In function 'int32_t main()':
strah.cpp:49:11: warning: unused variable 'mn' [-Wunused-variable]
int mn = INT_MAX;
^~
# |
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 |
0 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2484 KB |
Output is correct |
2 |
Correct |
14 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2424 KB |
Output is correct |
2 |
Correct |
15 ms |
2580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2428 KB |
Output is correct |
2 |
Correct |
17 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
8528 KB |
Output is correct |
2 |
Correct |
308 ms |
15048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
314 ms |
13392 KB |
Output is correct |
2 |
Correct |
481 ms |
19392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
213 ms |
8716 KB |
Output is correct |
2 |
Correct |
346 ms |
16136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
12276 KB |
Output is correct |
2 |
Correct |
411 ms |
18796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
728 ms |
20028 KB |
Output is correct |
2 |
Correct |
521 ms |
23892 KB |
Output is correct |