#include <bits/stdc++.h>
/*
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")*/
#define I inline void
#define S struct
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1e5 + 7, mod = 1e9 + 7;
const int inf = N;
// How interesting!
int n, m;
int v[N];
ll ans;
void solve()
{
for (int i = 0; i < m; ++i)
{
int j1 = i, j2 = i;
while (j1 && v[j1 - 1] > v[i])
--j1;
while (j2 + 1 < m && v[j2 + 1] >= v[i])
++j2;
ll contr = 0;
ll l1 = i - j1, l2 = j2 - i;
for (int j = 0; j <= l1; ++j)
{
for (int k = 0; k <= l2; ++k)
{
ans += 1ll * (j + k + 1) * v[i] * (v[i] + 1) / 2ll;
}
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("in.in", "r", stdin);
cin >> n >> m;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
char c;
cin >> c;
if (c == '.')
v[j]++;
else
v[j] = 0;
}
solve();
}
cout << ans;
return 0;
}
Compilation message
strah.cpp: In function 'void solve()':
strah.cpp:38:20: warning: unused variable 'contr' [-Wunused-variable]
38 | ll contr = 0;
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
384 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
512 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
384 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
722 ms |
1400 KB |
Output is correct |
2 |
Execution timed out |
1087 ms |
1916 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1095 ms |
1528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1082 ms |
1784 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
640 KB |
Output is correct |
2 |
Execution timed out |
1094 ms |
1920 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1079 ms |
1660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |