fork(2) download
  1. int Solution::lis(const vector<int> &A) {
  2. set<int> s;
  3. set<int> :: iterator itr;
  4. unordered_map<int,int> m;
  5. vector<int> lis(A.size()), temp(A.size()+1,INT_MAX);
  6. int ans = 1;
  7. if(!A.size()) return 0;
  8. s.insert(-A[0]);
  9. m[A[0]] = 0;
  10. lis[0] = 1;
  11. temp[1] = A[0];
  12. for(int i=1; i<A.size(); i++){
  13. itr = upper_bound(s.begin(), s.end(), -A[i]);
  14. if(itr == s.end()){
  15. lis[i] = 1;
  16. }
  17. else{
  18. lis[i] = lis[m[-*itr]] + 1;
  19. }
  20. ans = max(ans, lis[i]);
  21. s.insert(-A[i]);
  22. m[A[i]] = i;
  23. if(A[i] < temp[lis[i]]){
  24. if(temp[lis[i]] != INT_MAX){
  25. m.erase(temp[lis[i]]);
  26. s.erase(-temp[lis[i]]);
  27. }
  28. temp[lis[i]] = A[i];
  29. }
  30. }
  31. // for(int i=0; i<A.size(); i++) cout<<lis[i]<<" ";
  32. return ans;
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:5: error: ‘Solution’ has not been declared
 int Solution::lis(const vector<int> &A) {
     ^~~~~~~~
prog.cpp:1:25: error: ‘vector’ does not name a type
 int Solution::lis(const vector<int> &A) {
                         ^~~~~~
prog.cpp:1:31: error: expected ‘,’ or ‘...’ before ‘<’ token
 int Solution::lis(const vector<int> &A) {
                               ^
prog.cpp: In function ‘int lis(int)’:
prog.cpp:2:5: error: ‘set’ was not declared in this scope
     set<int> s;
     ^~~
prog.cpp:2:9: error: expected primary-expression before ‘int’
     set<int> s;
         ^~~
prog.cpp:3:9: error: expected primary-expression before ‘int’
     set<int> :: iterator itr;
         ^~~
prog.cpp:4:5: error: ‘unordered_map’ was not declared in this scope
     unordered_map<int,int> m;
     ^~~~~~~~~~~~~
prog.cpp:4:19: error: expected primary-expression before ‘int’
     unordered_map<int,int> m;
                   ^~~
prog.cpp:5:5: error: ‘vector’ was not declared in this scope
     vector<int> lis(A.size()), temp(A.size()+1,INT_MAX);
     ^~~~~~
prog.cpp:5:12: error: expected primary-expression before ‘int’
     vector<int> lis(A.size()), temp(A.size()+1,INT_MAX);
            ^~~
prog.cpp:7:9: error: ‘A’ was not declared in this scope
     if(!A.size())   return 0;
         ^
prog.cpp:8:5: error: ‘s’ was not declared in this scope
     s.insert(-A[0]);
     ^
prog.cpp:8:15: error: ‘A’ was not declared in this scope
     s.insert(-A[0]);
               ^
prog.cpp:9:5: error: ‘m’ was not declared in this scope
     m[A[0]] = 0;
     ^
prog.cpp:10:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     lis[0] = 1;
          ^
prog.cpp:10:14: error: assignment of function ‘int lis(int)’
     lis[0] = 1;
              ^
prog.cpp:10:14: error: cannot convert ‘int’ to ‘int(int)’ in assignment
prog.cpp:11:5: error: ‘temp’ was not declared in this scope
     temp[1] = A[0];
     ^~~~
prog.cpp:13:9: error: ‘itr’ was not declared in this scope
         itr = upper_bound(s.begin(), s.end(), -A[i]);
         ^~~
prog.cpp:13:52: error: ‘upper_bound’ was not declared in this scope
         itr = upper_bound(s.begin(), s.end(), -A[i]);
                                                    ^
prog.cpp:15:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             lis[i] = 1;
                  ^
prog.cpp:15:22: error: assignment of read-only location ‘*(lis + ((sizetype)i))’
             lis[i] = 1;
                      ^
prog.cpp:15:22: error: cannot convert ‘int’ to ‘int(int)’ in assignment
prog.cpp:18:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             lis[i] = lis[m[-*itr]] + 1;
                  ^
prog.cpp:20:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         ans = max(ans, lis[i]);
                             ^
prog.cpp:20:30: error: ‘max’ was not declared in this scope
         ans = max(ans, lis[i]);
                              ^
prog.cpp:23:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         if(A[i] < temp[lis[i]]){
                             ^
prog.cpp:24:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             if(temp[lis[i]] != INT_MAX){
                          ^
prog.cpp:24:32: error: ‘INT_MAX’ was not declared in this scope
             if(temp[lis[i]] != INT_MAX){
                                ^~~~~~~
prog.cpp:25:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
                 m.erase(temp[lis[i]]);
                                   ^
prog.cpp:26:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
                 s.erase(-temp[lis[i]]);
                                    ^
prog.cpp:28:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             temp[lis[i]] = A[i];
                       ^
stdout
Standard output is empty