Submission #256825

#TimeUsernameProblemLanguageResultExecution timeMemory
256825uacoder123Strah (COCI18_strah)C++14
88 / 110
1094 ms39416 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); lli n,m; cin>>n>>m; char arr[n][m]; lli arr1[n][m]; for(lli i=0;i<n;++i) for(lli j=0;j<m;++j) cin>>arr[i][j]; for(lli j=0;j<m;++j) { lli c=-1; for(lli i=0;i<n;++i) { if(arr[i][j]=='#') c=i; else arr1[i][j]=c; } } lli ans=0; for(lli i=0;i<n;++i) { for(lli j=0;j<m;++j) { lli c=-1; if(arr[i][j]=='#') continue; for(lli k=j;k>=0;--k) { if(arr[i][k]=='#') break; c=max(c,arr1[i][k]); ans+=(j-k+1)*(i-(c+1)+1)*(i-(c+1)+1+1)/2; } } } cout<<ans<<endl; return(0); }
#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...