Submission #771368

# Submission time Handle Problem Language Result Execution time Memory
771368 2023-07-02T22:55:17 Z tigar Unscrambling a Messy Bug (IOI16_messy) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "messy.h"

using namespace std;

map<int, int>permutation;

vector<string> adding(int n)
{
    vector<string>ans;
    if(n==0)return ans;
    string s, s1;
    for(int i=0; i<n; i++)s+='0';
    for(int i=0; i<n/2; i++){s[i]='1'; ans.push_back(s); s[i]='0'; s1+='1';}
    vector<string>p=adding(n/2);
    for(int i=0; i<p.size(); i++){ans.push_back(p[i]+s1); ans.push_back(s1+p[i]);}
    return ans;
}

void reading(int l, int r, vector<int>possible)
{
    vector<int>ans1, ans2;
    if(l==r+1)
    {
        string s;
        for(int i=0; i<n; i++)
        {
            if(i==possible[1])s+='0'
            else s+='1';
        }
        if(check_element(s)){permutation[l]=possible[0]; permutation[r]=possible[1];}
        else {permutation[l]=possible[0]; permission[r]=possible[1];}
        return;
    }
    string s;
    for(int i=0; i<n; i++)s+='1';
    for(int i=0; i<possible.size(); i++)s[possible[i]]='0';
    for(int i=0; i<possible.size(); i++)
    {
        s[possible[i]]='1';
        if(check_element(s))ans1.push_back(possible[i]);
        else ans2.push_back(possible[i]);
        s[possible[i]]='0'; 
    }
    reading(l, (l+r)/2-1, ans1);
    reading((r+l)/2, r, ans2);
    return;
}

std::vector<int>
//void
restore_permutation(int n, int w, int r)
{
    vector<string>a=adding(n);
    for(int i=0; i<a.size(); i++)add_element(a[i]);
    compile_set();
    vector<int>b;
    for(int i=0; i<n; i++)b.push_back(i);
    reading(0, n-1, b);
    vector<int>ans;
    for(int i=0; i<n; i++)ans.push_back(permutation[i]);
    return ans;
}

Compilation message

messy.cpp: In function 'std::vector<std::__cxx11::basic_string<char> > adding(int)':
messy.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0; i<p.size(); i++){ans.push_back(p[i]+s1); ans.push_back(s1+p[i]);}
      |                  ~^~~~~~~~~
messy.cpp: In function 'void reading(int, int, std::vector<int>)':
messy.cpp:26:24: error: 'n' was not declared in this scope
   26 |         for(int i=0; i<n; i++)
      |                        ^
messy.cpp:28:37: error: expected ';' before 'else'
   28 |             if(i==possible[1])s+='0'
      |                                     ^
      |                                     ;
   29 |             else s+='1';
      |             ~~~~                     
messy.cpp:32:43: error: 'permission' was not declared in this scope
   32 |         else {permutation[l]=possible[0]; permission[r]=possible[1];}
      |                                           ^~~~~~~~~~
messy.cpp:36:20: error: 'n' was not declared in this scope
   36 |     for(int i=0; i<n; i++)s+='1';
      |                    ^
messy.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0; i<possible.size(); i++)s[possible[i]]='0';
      |                  ~^~~~~~~~~~~~~~~~
messy.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=0; i<possible.size(); i++)
      |                  ~^~~~~~~~~~~~~~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i=0; i<a.size(); i++)add_element(a[i]);
      |                  ~^~~~~~~~~