fork download
  1. int N,a[N];
  2. int l[N],p[N],maxl=1,maxp=0;
  3. Map<int,int> m; // <ключ,значение>
  4. for(int i=0;i<N;++i) {
  5. Map<int,int>* iter=m.Find(a[i],GreaterEqual);
  6. if(iter) {
  7. int j=*iter;
  8. if(a[i]==a[j])
  9. m.Del(iter);
  10. p[i]=j;
  11. l[i]=l[j]+1
  12. if(l[i]>maxl) {
  13. maxl=l[i];
  14. maxp=i
  15. }
  16. }
  17. else {
  18. p[i]=-1;
  19. l[i]=1;
  20. }
  21. m.Add(a[i],i);
  22. }
  23. // выписать индексы в массив
  24. int i=maxp,j=l[i],m=j;
  25. int s[m];
  26. for(;i>=0;i=p[i])
  27. s[--j]=i;
  28. // обратить s[m]
  29. for(i=0,j=m;i<--j;++i)
  30. swap(s[i],s[j]);
  31. // печать
  32. print(l[maxp]);
  33. for(i=0;i<m;++i)
  34. print(s[i]);
  35.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:12: error: array bound is not an integer constant before ']' token
   int N,a[N];
            ^
prog.cpp:2:10: error: array bound is not an integer constant before ']' token
   int l[N],p[N],maxl=1,maxp=0;
          ^
prog.cpp:2:15: error: array bound is not an integer constant before ']' token
   int l[N],p[N],maxl=1,maxp=0;
               ^
prog.cpp:3:3: error: 'Map' does not name a type
   Map<int,int> m; // <ключ,значение>
   ^
prog.cpp:4:3: error: expected unqualified-id before 'for'
   for(int i=0;i<N;++i) {
   ^
prog.cpp:4:15: error: 'i' does not name a type
   for(int i=0;i<N;++i) {
               ^
prog.cpp:4:19: error: expected unqualified-id before '++' token
   for(int i=0;i<N;++i) {
                   ^
stdout
Standard output is empty