Submission #163721

# Submission time Handle Problem Language Result Execution time Memory
163721 2019-11-14T19:25:56 Z beso123 Bob (COCI14_bob) C++14
0 / 120
1000 ms 38484 KB
#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

bob.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 760 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 632 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 8824 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 643 ms 9336 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 9692 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 9804 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 36652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 38408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 38484 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 37732 KB Time limit exceeded
2 Halted 0 ms 0 KB -