Submission #1074463

#TimeUsernameProblemLanguageResultExecution timeMemory
1074463YassineBenYounesUnscrambling a Messy Bug (IOI16_messy)C++17
Compilation error
0 ms0 KiB
#include "messy.h" #include <bits/stdc++.h> #include <vector> #include <cstdio> #include <string> #include <set> #include <cstdlib> #include <iostream> #define vi vector<int> #define pb push_back int sz; vector<string> ask; vi res; void preprocess(int l, int r){ if(l == r)return; string s(sz, '0'); for(int i = 0; i < l;i++){ s[i] = '1'; } for(int i = r+1; i < sz;i++){ s[i] = '1'; } int md = (l+r)/2; for(int i = l;i <= md;i++){ s[i] = '1'; ask.pb(s); s[i] = '0'; } preprocess(l, md); preprocess(md+1, r); } string cur; void solve(int l, int r, set<int> possible){ if(possible.size() == 1){ res[l] = *possible.begin(); return; } set<int> left; for(int x : possible){ cur[x] = '1'; //cout << cur << endl; bool k = check_element(cur); if(k){ left.insert(x); } cur[x] = '0'; } set<int> right = possible; for(int x : left){ right.erase(x); } int md = (l+r)/2; for(int x : right){ cur[x] = '1'; } solve(l, md, left); for(int x : right){ cur[x] = '0'; } for(int x : left){ cur[x] = '1'; } solve(md+1, r, right); for(int x : left){ cur[x] = '0'; } } std::vector<int> restore_permutation(int N, int w, int r) { sz = N; preprocess(0, sz-1); for(string s: ask){ //cout << s << endl; add_element(s); } compile_set(); res.resize(sz); //cout << endl; //res = {7, 6, 5, 4, 3, 2, 1, 0}; set<int> mys; for(int i = 0; i < sz;i++){ mys.insert(i); } cur.resize(sz, '0'); solve(0, sz-1, mys); return res; }

Compilation message (stderr)

messy.cpp:14:1: error: 'vector' does not name a type
   14 | vector<string> ask;
      | ^~~~~~
messy.cpp:9:12: error: 'vector' does not name a type
    9 | #define vi vector<int>
      |            ^~~~~~
messy.cpp:15:1: note: in expansion of macro 'vi'
   15 | vi res;
      | ^~
messy.cpp: In function 'void preprocess(int, int)':
messy.cpp:18:5: error: 'string' was not declared in this scope
   18 |     string s(sz, '0');
      |     ^~~~~~
messy.cpp:18:5: note: suggested alternatives:
In file included from /usr/include/c++/10/string:39,
                 from messy.h:4,
                 from messy.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from messy.h:4,
                 from messy.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
messy.cpp:20:9: error: 's' was not declared in this scope
   20 |         s[i] = '1';
      |         ^
messy.cpp:23:9: error: 's' was not declared in this scope
   23 |         s[i] = '1';
      |         ^
messy.cpp:27:9: error: 's' was not declared in this scope
   27 |         s[i] = '1';
      |         ^
messy.cpp:28:9: error: 'ask' was not declared in this scope
   28 |         ask.pb(s);
      |         ^~~
messy.cpp: At global scope:
messy.cpp:35:1: error: 'string' does not name a type; did you mean 'stdin'?
   35 | string cur;
      | ^~~~~~
      | stdin
messy.cpp:37:26: error: 'set' has not been declared
   37 | void solve(int l, int r, set<int> possible){
      |                          ^~~
messy.cpp:37:29: error: expected ',' or '...' before '<' token
   37 | void solve(int l, int r, set<int> possible){
      |                             ^
messy.cpp: In function 'void solve(int, int, int)':
messy.cpp:38:8: error: 'possible' was not declared in this scope
   38 |     if(possible.size() == 1){
      |        ^~~~~~~~
messy.cpp:39:9: error: 'res' was not declared in this scope
   39 |         res[l] = *possible.begin();
      |         ^~~
messy.cpp:42:5: error: 'set' was not declared in this scope
   42 |     set<int> left;
      |     ^~~
messy.cpp:42:5: note: suggested alternatives:
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from messy.cpp:2:
/usr/include/c++/10/bits/stl_set.h:94:11: note:   'std::set'
   94 |     class set
      |           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from messy.cpp:2:
/usr/include/c++/10/set:78:13: note:   'std::pmr::set'
   78 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
messy.cpp:42:9: error: expected primary-expression before 'int'
   42 |     set<int> left;
      |         ^~~
messy.cpp:43:17: error: 'possible' was not declared in this scope
   43 |     for(int x : possible){
      |                 ^~~~~~~~
messy.cpp:44:9: error: 'cur' was not declared in this scope
   44 |         cur[x] = '1';
      |         ^~~
messy.cpp:49:13: error: 'left' was not declared in this scope; did you mean 'std::left'?
   49 |             left.insert(x);
      |             ^~~~
      |             std::left
In file included from /usr/include/c++/10/ios:42,
                 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:2:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: 'std::left' declared here
 1006 |   left(ios_base& __base)
      |   ^~~~
messy.cpp:53:9: error: expected primary-expression before 'int'
   53 |     set<int> right = possible;
      |         ^~~
messy.cpp:54:17: error: 'left' was not declared in this scope; did you mean 'std::left'?
   54 |     for(int x : left){
      |                 ^~~~
      |                 std::left
In file included from /usr/include/c++/10/ios:42,
                 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:2:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: 'std::left' declared here
 1006 |   left(ios_base& __base)
      |   ^~~~
messy.cpp:55:9: error: 'right' was not declared in this scope; did you mean 'std::right'?
   55 |         right.erase(x);
      |         ^~~~~
      |         std::right
In file included from /usr/include/c++/10/ios:42,
                 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:2:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: 'std::right' declared here
 1014 |   right(ios_base& __base)
      |   ^~~~~
messy.cpp:58:17: error: 'right' was not declared in this scope; did you mean 'std::right'?
   58 |     for(int x : right){
      |                 ^~~~~
      |                 std::right
In file included from /usr/include/c++/10/ios:42,
                 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:2:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: 'std::right' declared here
 1014 |   right(ios_base& __base)
      |   ^~~~~
messy.cpp:59:9: error: 'cur' was not declared in this scope
   59 |         cur[x] = '1';
      |         ^~~
messy.cpp:61:18: error: 'left' was not declared in this scope; did you mean 'std::left'?
   61 |     solve(l, md, left);
      |                  ^~~~
      |                  std::left
In file included from /usr/include/c++/10/ios:42,
                 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:2:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: 'std::left' declared here
 1006 |   left(ios_base& __base)
      |   ^~~~
messy.cpp:62:17: error: 'right' was not declared in this scope; did you mean 'std::right'?
   62 |     for(int x : right){
      |                 ^~~~~
      |                 std::right
In file included from /usr/include/c++/10/ios:42,
                 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:2:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: 'std::right' declared here
 1014 |   right(ios_base& __base)
      |   ^~~~~
messy.cpp:63:9: error: 'cur' was not declared in this scope
   63 |         cur[x] = '0';
      |         ^~~
messy.cpp:66:9: error: 'cur' was not declared in this scope
   66 |         cur[x] = '1';
      |         ^~~
messy.cpp:68:20: error: 'right' was not declared in this scope; did you mean 'std::right'?
   68 |     solve(md+1, r, right);
      |                    ^~~~~
      |                    std::right
In file included from /usr/include/c++/10/ios:42,
                 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:2:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: 'std::right' declared here
 1014 |   right(ios_base& __base)
      |   ^~~~~
messy.cpp:70:9: error: 'cur' was not declared in this scope
   70 |         cur[x] = '0';
      |         ^~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:77:9: error: 'string' was not declared in this scope
   77 |     for(string s: ask){
      |         ^~~~~~
messy.cpp:77:9: note: suggested alternatives:
In file included from /usr/include/c++/10/string:39,
                 from messy.h:4,
                 from messy.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from messy.h:4,
                 from messy.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
messy.cpp:81:16: error: could not convert 'compile_set()' from 'void' to 'bool'
   81 |     compile_set();
      |     ~~~~~~~~~~~^~
      |                |
      |                void
messy.cpp:82:5: error: 'res' was not declared in this scope
   82 |     res.resize(sz);
      |     ^~~
messy.cpp:82:19: error: expected ')' before ';' token
   82 |     res.resize(sz);
      |                   ^
      |                   )
messy.cpp:77:8: note: to match this '('
   77 |     for(string s: ask){
      |        ^
messy.cpp:85:5: error: 'set' was not declared in this scope
   85 |     set<int> mys;
      |     ^~~
messy.cpp:85:5: note: suggested alternatives:
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from messy.cpp:2:
/usr/include/c++/10/bits/stl_set.h:94:11: note:   'std::set'
   94 |     class set
      |           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from messy.cpp:2:
/usr/include/c++/10/set:78:13: note:   'std::pmr::set'
   78 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
messy.cpp:85:9: error: expected primary-expression before 'int'
   85 |     set<int> mys;
      |         ^~~
messy.cpp:87:9: error: 'mys' was not declared in this scope
   87 |         mys.insert(i);
      |         ^~~
messy.cpp:89:5: error: 'cur' was not declared in this scope
   89 |     cur.resize(sz, '0');
      |     ^~~
messy.cpp:90:20: error: 'mys' was not declared in this scope
   90 |     solve(0, sz-1, mys);
      |                    ^~~
messy.cpp:91:12: error: 'res' was not declared in this scope
   91 |     return res;
      |            ^~~