Submission #810603

#TimeUsernameProblemLanguageResultExecution timeMemory
810603AndreyUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
1 ms468 KiB
#include <vector>
#include<bits/stdc++.h>
#include "messy.h"
using namespace std;

string s = "";
vector<int> ans(0);

void yay(int l, int r) {
    if(l == r) {
        return;
    }
    int m = (l+r)/2;
    yay(l,m);
    yay(m+1,r);
    for(int i = l; i <= m; i++) {
        for(int j = 0; j < s.size(); j++) {
            if(j >= l && j <= r) {
                s[j] = '1';
            }
            else {
                s[j] = '0';
            }
        }
        s[i] = '0';
        add_element(s);
    }
}

void dude(int l, int r, vector<int> haha) {
    if(l == r) {
        ans[haha[0]] = l;
        return;
    }
    vector<int> a(0);
    vector<int> b(0);
    int m = (l+r)/2;
    for(int i = 0; i < s.size(); i++) {
        s[i] = '0';
    }
    for(int i = 0; i < haha.size(); i++) {
        s[haha[i]] = '1';
    }
    for(int i = 0; i < haha.size(); i++) {
        s[haha[i]] = '0';
        if(check_element(s)) {
            a.push_back(haha[i]);
        }
        else {
            b.push_back(haha[i]);
        }
        s[haha[i]] = '1';
    }
    dude(l,m,a);
    dude(m+1,r,b);
}

vector<int> restore_permutation(int n, int w, int r) {
    for(int i = 0; i < n; i++) {
        s+='1';
        ans.push_back(0);
    }
    yay(0,n-1);
    compile_set();
    vector<int> wut(0);
    for(int i = 0; i < n; i++) {
        wut.push_back(i);
    }
    dude(0,n-1,wut);
    return ans;
}

Compilation message (stderr)

messy.cpp: In function 'void yay(int, int)':
messy.cpp:17:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for(int j = 0; j < s.size(); j++) {
      |                        ~~^~~~~~~~~~
messy.cpp: In function 'void dude(int, int, std::vector<int>)':
messy.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
messy.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i = 0; i < haha.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
messy.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i = 0; i < haha.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...