Submission #1199087

#TimeUsernameProblemLanguageResultExecution timeMemory
1199087djs100201Unscrambling a Messy Bug (IOI16_messy)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include "messy.h"
set<int>candidate[128];
vector<int> restore_permutation(int n, int w, int r)
{
    vector<int> res(n), rev(n),pl(3);
    //일단 0,1,2는 알아야 함
    for(int i=1;i<8;i++){
        string S(n, '0'), temp(n, '0');
        if(i&1)S[0]='1';
        if(i&2)S[1]='1';
        if(i&4)S[2]='1';
        for(int j=3;j<n;j++){
            if(j&(1<<(i-1)))S[j]='1';
        }
        add_element(S);
    }
    string S(n, '1');
    for (int i = 0; i < 3; i++)
    {
        S[i] = '0';
        add_element(S);
    }
    compile_set();
    string temp(n,'0');
    for (int ii = 0; ii < 3; ii++)
    {
        for (int i = 0; i < n; i++)
        {
            if (temp[i] == '1')
                continue;
            temp[i] = '1';
            if (check_element(temp))
            {
                res[i] = ii;
                pl[ii]=i;
                break;
            }
            temp[i] = '0';
        }
    }
    for(int i=3;i<n;i++){
        for(int j=0;j<n;j++){
            if(pl[0]==j || pl[1]==j || pl[2]==j)continue;
            candidate[i].push_back(j);
            //i->j였음.
        }
    }
    for(int i=1;i<8;i++){
        string S(n, '0'), temp;
        if(i&1)S[0]='1';
        if(i&2)S[1]='1';
        if(i&4)S[2]='1';
        vector<int>checked(n);
        for(int j=0;j<n;j++){
            if(pl[0]==j || pl[1]==j || pl[2]==j)continue;
            temp=S;
            temp[j]='1';
            if(check_element(temp))checked[j]=1;
        }
        for(int j=3;j<n;j++){
            if(j&(1<<(i-1))){
                for (auto it = st[j].begin(); it != st[j].end(); ) {
                    if (!checked[*it]) {
                        it = st[j].erase(it);  // erase는 삭제 후 다음 iterator 반환
                    } else {
                        ++it;
                    }
                }
            }
        }
    }
    for(int i=3;i<n;i++){
        int x=*st[i].begin();
        res[x]=i;
    }
    return res;
}

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:47:26: error: 'class std::set<int>' has no member named 'push_back'
   47 |             candidate[i].push_back(j);
      |                          ^~~~~~~~~
messy.cpp:65:32: error: 'st' was not declared in this scope; did you mean 'it'?
   65 |                 for (auto it = st[j].begin(); it != st[j].end(); ) {
      |                                ^~
      |                                it
messy.cpp:76:16: error: 'st' was not declared in this scope; did you mean 'std'?
   76 |         int x=*st[i].begin();
      |                ^~
      |                std
messy.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
messy_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~