Submission #163721

#TimeUsernameProblemLanguageResultExecution timeMemory
163721beso123Bob (COCI14_bob)C++14
0 / 120
1090 ms38484 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int n,m,a[1001][1001],ans; void NOW(int x){ int dp[n+1][m+1],w[n+1][m+1]; dp[0][0]=0; for(int k=1;k<=n;k++){ stack <int> st; for(int i=1;i<=m;i++){ dp[k][0]=0; dp[0][i]=0; dp[k][i]=0; w[k][i]=0; if(a[k][i]!=x) continue; if(a[k-1][i]!=x) w[k][i]=1; else w[k][i]=w[k-1][i]+1; int h=i-1; if(st.size()!=0){ while(st.size()>0 && w[k][st.top()]>=w[k][i]){ st.pop(); } if(st.size()!=0) h=st.top(); } st.push(i); dp[k][i]=(i-h)*w[k][i]+dp[k][h]; ans+=dp[k][i]; } } } main(){ cin>>n>>m; set<int> s; for(int k=1;k<=n;k++) for(int i=1;i<=m;i++){ cin>>a[k][i]; s.insert(a[k][i]); } for(auto it=s.begin();it!=s.end();it++){ NOW(*it); } cout<<ans; return 0; }

Compilation message (stderr)

bob.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#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...