Блог пользователя roben_76

Автор roben_76, 11 лет назад, По-английски

hello, would you tell me why my answer doesn't work?

please help me to know why doesn't work.

and you could see the submission here:4713882

`

include

include<stdio.h>

include<stdlib.h>

include

include

include

include

include<string.h>

include

define pb push_back

define limit 5000

define mp make_pair

define ff first.first

define fs first.second

using namespace std;

int main(){

int n,w,h;
cin>>n>>w>>h;
pair<pair<int,int>,int> a[n];
for(int i=0;i<n;i++){
    cin>>a[i].first.first;
    cin>>a[i].first.second;
    a[i].second=i;

}
sort(a,a+n);

vector<int> v[n+1];
for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
       if(a[j].ff>a[i].ff && a[j].fs>a[i].fs){
         v[i].pb(j);
       }
    }

}
for(int i=0;i<n;i++){
    if(a[i].ff>w&&a[i].fs>h){
       v[n].pb(i);
    }
}
if(v[n].size()==0){
    cout<<"0";
    return 0;
}
int len[n+1],maxl=0;
for(int i=0;i<=n;i++){
    len[i]=0;
}
for(int i=n-1;i>=0;i--){
    maxl=-1;
    if(v[i].size()==0){
       len[i]=0;
    }
    else{
       for(int j=0;j<v[i].size();j++){
         if(len[v[i][j]]>maxl)
          maxl=len[v[i][j]];
       }
       len[i]=maxl+1;
    }
}
maxl=-1;
int maxi=0;
for(int i=0;i<v[n].size();i++){
    if(len[v[n][i]]>maxl){
       maxl=len[v[n][i]];
       maxi=v[n][i];
    }
}

len[n]=maxl+1;
int s[maxl+1];
for(int i=0;i<=maxl;i++){
    s[i]=0;
}
while(maxl>=0){
    s[len[n]-maxl-1]=maxi;
    maxl--;
    if(maxl>=0){
       for(int i=0;i<v[maxi].size();i++){
         if(v[v[maxi][i]].size()==maxl){
          maxi=v[maxi][i];
          break;
         }
       }
    }
}
cout<<len[n]<<endl;
for(int i=0;i<len[n];i++){
    cout<<a[s[i]].second+1<<" ";
}
cout<<endl;
return 0;

}

` thanks

  • Проголосовать: нравится
  • -20
  • Проголосовать: не нравится