Submission #603961

# Submission time Handle Problem Language Result Execution time Memory
603961 2022-07-24T14:05:30 Z neki Unscrambling a Messy Bug (IOI16_messy) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "messy.h"
#define vc vector

using namespace std;

void badd(int l, int r, int n){
    if(l+1==r) return;
    
    int mid=(l+r)/2;
    
    string s(n, '1');
    for(int i=l; i<r;++i) s[i]='0';
    for(int i=l; i<mid;++i){
        string t=s;
        t[i]='1';
        add(t);
    }
    
    badd(l, mid, n);
    badd(mid, r, n);
}

void bquery(int l, int r, int n, vc<int>& ans){
    if(l+1==r) return;
    
    int mid=(l+r)/2;
    
    string s(n, '1');
    for(int i=l; i<r;++i) s[ans[i]]='0';
    
    set<int> ls, rs;
    for(int i=l; i<r;++i){
        string t=s;
        t[ans[i]]='1';
        if(check_element(t)) ls.insert(ans[i]);
        else  rs.insert(ans[i]);
    }
    vc<int> lv(ls.begin(), ls.end()), rv(rs.begin(), rs.end());
    assert(lv.size()==(mid-l) and rv.size()==(r-mid));
    for(int i=l;i<mid;++i) ans[i]=lv[i-l];
    for(int i=mid;i<r;++i) ans[i]=rv[i-mid];
    
    bquery(l, mid, n, ans);
    bquery(mid, r, n, ans);
}

vc<int> inv(vc<int> ans){
    vc<int> ret(ans.size());
    for(int i=0;i<ans.size();++i) ret[ans[i]]=i;
    return ret;
}

vc<int> restore_permutation(int n, int w, int r){
    badd(0, n, n);
    compileset();
    
    vc<int> ans(n); for(int i=0;i<n;++i) ans[i]=i;
    bquery(0, n, n, ans);
    return inv(ans);
}

Compilation message

messy.cpp: In function 'void badd(int, int, int)':
messy.cpp:17:9: error: 'add' was not declared in this scope; did you mean 'badd'?
   17 |         add(t);
      |         ^~~
      |         badd
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from messy.cpp:1:
messy.cpp: In function 'void bquery(int, int, int, std::vector<int>&)':
messy.cpp:40:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     assert(lv.size()==(mid-l) and rv.size()==(r-mid));
      |            ~~~~~~~~~^~~~~~~~~
messy.cpp:40:44: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     assert(lv.size()==(mid-l) and rv.size()==(r-mid));
      |                                   ~~~~~~~~~^~~~~~~~~
messy.cpp: In function 'std::vector<int> inv(std::vector<int>)':
messy.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=0;i<ans.size();++i) ret[ans[i]]=i;
      |                 ~^~~~~~~~~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:56:5: error: 'compileset' was not declared in this scope; did you mean 'compile_set'?
   56 |     compileset();
      |     ^~~~~~~~~~
      |     compile_set