# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
855781 |
2023-10-01T19:23:02 Z |
vjudge1 |
Strah (COCI18_strah) |
C++17 |
|
1000 ms |
34792 KB |
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
#define lim 200005
using namespace std;
bool cmp(const ii &l,const ii &r) {
if(l.st < r.st) return true;
if(l.st > r.st) return false;
return l.nd < r.nd;
}
int les(int x){
return (x * (x+1))/2;
}
void solve(){
int n,m; cin >> n >> m;
int rel[n+1][m+1];
for(int i=1; i<=m; i++) rel[0][i]=0;
for(int i=1; i<=n; i++){
string s; cin >> s;
for(int j=1; j<=m; j++){
if(s[j-1]=='#') rel[i][j] = 0;
else rel[i][j] = rel[i-1][j]+1;
//cerr << rel[i][j] << " ";
}
//cerr << endl;
}
int pref[n+1]; pref[0]=0;
ii cur[n+1]; cur[0]={0, 0};
int add[n+1]; add[0]=0;
int end, ans=0;
for(int k=1; k<=n; k++){
end=0;
for(int i=1; i<=m; i++){
end = lower_bound(cur, cur+end+1, mp(rel[k][i], i)) - cur;
cur[end] = mp(rel[k][i], i);
add[end] = add[end-1] + (les(cur[end].st) * (cur[end].nd-cur[end-1].nd));
pref[end] = pref[end-1] + (add[end-1] * (cur[end].nd - cur[end-1].nd)) + (les(cur[end].st) * les(cur[end].nd - cur[end-1].nd));
cerr << end spc add[end] spc pref[end] spc pref[end-1] << " :: ";
ans += pref[end];
}
cerr << endl;
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
785 ms |
2312 KB |
Output is correct |
2 |
Correct |
831 ms |
2516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
875 ms |
2388 KB |
Output is correct |
2 |
Correct |
780 ms |
2480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
800 ms |
3924 KB |
Output is correct |
2 |
Correct |
847 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
10692 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
21244 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1029 ms |
14920 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
3864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
34792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |