fork download
  1. #include<iostream>
  2. #include<map>
  3.  
  4. void unlock(map<long long int,int>m, int n, long long int k){
  5. for(long long int i=n;i>=0;i--){
  6. long long int number = i;
  7. int best_pos = i-nmbr;
  8. for(long long int j=0;j<k;j++){
  9. if(m[n]!=best_pos){
  10. swap(m[n],best_pos);
  11. }
  12. }
  13. }
  14. }
  15. int main() {
  16. int n;
  17. long long int k,arr[100003],map<long long int,int>m;
  18. cin>>n>>k;
  19. for(long long int i=0;i<n;i++){
  20. cin>>arr[i];
  21. m.insert(make_pair(arr[i],i));
  22. }
  23. unlock(m,n,k);
  24. for(auto it: m){
  25. cout<<it.first<<" ";
  26. }
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:13: error: variable or field ‘unlock’ declared void
 void unlock(map<long long int,int>m, int n, long long int k){
             ^~~
prog.cpp:4:13: error: ‘map’ was not declared in this scope
prog.cpp:4:13: note: suggested alternative:
In file included from /usr/include/c++/8/map:61,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_map.h:100:11: note:   ‘std::map’
     class map
           ^~~
prog.cpp:4:17: error: expected primary-expression before ‘long’
 void unlock(map<long long int,int>m, int n, long long int k){
                 ^~~~
prog.cpp:4:31: error: expected primary-expression before ‘int’
 void unlock(map<long long int,int>m, int n, long long int k){
                               ^~~
prog.cpp:4:38: error: expected primary-expression before ‘int’
 void unlock(map<long long int,int>m, int n, long long int k){
                                      ^~~
prog.cpp:4:45: error: expected primary-expression before ‘long’
 void unlock(map<long long int,int>m, int n, long long int k){
                                             ^~~~
prog.cpp: In function ‘int main()’:
prog.cpp:17:33: error: expected initializer before ‘<’ token
  long long int k,arr[100003],map<long long int,int>m;
                                 ^
prog.cpp:18:2: error: ‘cin’ was not declared in this scope
  cin>>n>>k;
  ^~~
prog.cpp:18:2: note: suggested alternative:
In file included from prog.cpp:1:
/usr/include/c++/8/iostream:60:18: note:   ‘std::cin’
   extern istream cin;  /// Linked to standard input
                  ^~~
prog.cpp:21:3: error: ‘m’ was not declared in this scope
   m.insert(make_pair(arr[i],i));
   ^
prog.cpp:21:12: error: ‘make_pair’ was not declared in this scope
   m.insert(make_pair(arr[i],i));
            ^~~~~~~~~
prog.cpp:21:12: note: suggested alternative:
In file included from /usr/include/c++/8/bits/stl_algobase.h:64,
                 from /usr/include/c++/8/bits/char_traits.h:39,
                 from /usr/include/c++/8/ios:40,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/8/bits/stl_pair.h:524:5: note:   ‘std::make_pair’
     make_pair(_T1&& __x, _T2&& __y)
     ^~~~~~~~~
prog.cpp:23:9: error: ‘m’ was not declared in this scope
  unlock(m,n,k);
         ^
prog.cpp:23:2: error: ‘unlock’ was not declared in this scope
  unlock(m,n,k);
  ^~~~~~
prog.cpp:23:2: note: suggested alternative: ‘unlockpt’
  unlock(m,n,k);
  ^~~~~~
  unlockpt
prog.cpp:24:15: error: unable to deduce ‘auto&&’ from ‘m’
  for(auto it: m){
               ^
prog.cpp:25:9: error: ‘cout’ was not declared in this scope
         cout<<it.first<<" ";
         ^~~~
prog.cpp:25:9: note: suggested alternative:
In file included from prog.cpp:1:
/usr/include/c++/8/iostream:61:18: note:   ‘std::cout’
   extern ostream cout;  /// Linked to standard output
                  ^~~~
stdout
Standard output is empty