Submission #233552

#TimeUsernameProblemLanguageResultExecution timeMemory
233552alishahali1382Strah (COCI18_strah)C++14
77 / 110
171 ms16208 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O2") #pragma GCC optimize ("unroll-loops") //#pragma GCC optimize("no-stack-protector,fast-math") using namespace std; typedef unsigned long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<pii, int> piii; typedef pair<ll, ll> pll; #define debug(x) cerr<<#x<<'='<<(x)<<endl; #define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl; #define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl; #define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;} #define all(x) x.begin(), x.end() #define pb push_back #define kill(x) return cout<<x<<'\n', 0; const ld eps=1e-7; const int inf=1000000010; const ll INF=10000000000000010LL; const int mod=1000000007; const int N=2010; ll n, m, k, u, v, x, y, t, a, b, ans; int A[N][N]; ll L[N], R[N]; ll sum[N]; ll C2(ll x){ return x*(x+1)/2; } int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin>>n>>m; for (int i=1; i<=n; i++) for (int j=1; j<=m; j++){ char ch; cin>>ch; if (ch=='.') A[i][j]=(A[i-1][j]+1); } for (int i=1; i<=n; i++) for (int j=1; j<=i; j++) sum[i]+=j*(i-j+1ll); for (int i=1; i<=n; i++){ for (int j=1; j<=m; j++) for (L[j]=j-1; L[j] && A[i][L[j]]>=A[i][j]; L[j]=L[L[j]]); for (int j=m; j; j--) for (R[j]=j+1; R[j]<=m && A[i][R[j]]>A[i][j]; R[j]=R[R[j]]); for (int j=1; j<=m; j++) ans+=1ll*C2(A[i][j])*(sum[R[j]-L[j]-1]-sum[R[j]-j-1]-sum[j-L[j]-1]); } cout<<ans<<'\n'; return 0; } /* 2 3 .#. ..# */

Compilation message (stderr)

strah.cpp: In function 'int main()':
strah.cpp:40:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1; i<=n; i++) for (int j=1; j<=m; j++){
                ~^~~
strah.cpp:40:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1; i<=n; i++) for (int j=1; j<=m; j++){
                                         ~^~~
strah.cpp:45:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1; i<=n; i++) for (int j=1; j<=i; j++) sum[i]+=j*(i-j+1ll);
                ~^~~
strah.cpp:46:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1; i<=n; i++){
                ~^~~
strah.cpp:47:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=1; j<=m; j++) for (L[j]=j-1; L[j] && A[i][L[j]]>=A[i][j]; L[j]=L[L[j]]);
                 ~^~~
strah.cpp:49:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=1; j<=m; j++) ans+=1ll*C2(A[i][j])*(sum[R[j]-L[j]-1]-sum[R[j]-j-1]-sum[j-L[j]-1]);
                 ~^~~
#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...