Submission #1042306

#TimeUsernameProblemLanguageResultExecution timeMemory
1042306sofppUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "messy.h"

std::vector<int> restore_permutation(int n, int w, int r) {
    
    vector<int> vs(n,0);
    string c;
    for(int i=0;i<n;i++){
        c+='0';
    }
    string result=c;
    for(int i=n;i>=0;i--){
        c[i]='1';
        add_element(c);

        }
    compile_set();
    for(int i=0;i<n;i++){
        
        for(int j=0;j<n;j++){
            string h=result;
            if(h[j]=='1'){
                continue;
            }
            h[j]='1';
            if(check_element(h)==true){
                result[i]='1';
                vs[i]=j;
            }
        }
    }
    return vs;
}

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:6:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    6 |     vector<int> vs(n,0);
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from messy.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
messy.cpp:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> vs(n,0);
      |            ^~~
messy.cpp:7:5: error: 'string' was not declared in this scope; did you mean 'std::string'?
    7 |     string c;
      |     ^~~~~~
      |     std::string
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/ios:38,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from messy.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
messy.cpp:9:9: error: 'c' was not declared in this scope
    9 |         c+='0';
      |         ^
messy.cpp:11:11: error: expected ';' before 'result'
   11 |     string result=c;
      |           ^~~~~~~
      |           ;
messy.cpp:13:9: error: 'c' was not declared in this scope
   13 |         c[i]='1';
      |         ^
messy.cpp:21:19: error: expected ';' before 'h'
   21 |             string h=result;
      |                   ^~
      |                   ;
messy.cpp:22:16: error: 'h' was not declared in this scope
   22 |             if(h[j]=='1'){
      |                ^
messy.cpp:25:13: error: 'h' was not declared in this scope
   25 |             h[j]='1';
      |             ^
messy.cpp:27:17: error: 'result' was not declared in this scope
   27 |                 result[i]='1';
      |                 ^~~~~~
messy.cpp:28:17: error: 'vs' was not declared in this scope
   28 |                 vs[i]=j;
      |                 ^~
messy.cpp:32:12: error: 'vs' was not declared in this scope
   32 |     return vs;
      |            ^~