제출 #1187740

#제출 시각아이디문제언어결과실행 시간메모리
1187740Mamikonm1Unscrambling a Messy Bug (IOI16_messy)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#include<random>
#include "messy.h"

using namespace std;
mt19937 rd(time(nullptr));
void comp(string& a, vector<int>& f) {
    string b = string(n, '0');
    for (int i = 0; i < n; ++i)
        b[i] = a[f[i]];
    a = b;
}
vector<int> restore_permutation(int n, int w, int r) {
    vector<int>f(n), ans(n);
    vector<string>s(n, string(n, '0'));
    for (int i = 0; i < n; ++i) {
        f[i] = i;
        for (int j = 0; j <= i; ++j)
            s[i][j] = '1';
    }
    shuffle(begin(f), end(f), rd);

    for (int i = 0; i < n; ++i) {
        comp(s[i], f);
        add_element(s[i]);
    }
    compile_set();
    int ind;
    string t = string(n, '0'), g;
    g = t;
    for (int i = 0; i < n; ++i) {
        ind = 0;
        for (int j = 0; j < n; ++j) {
            if (g[j] == '0' and s[i][j] == '1') {
                ind = j;
            }
        }
        g[ind] = '1';
        for (int j = 0; j < n; ++j) {
            if (t[j] == '0') {
                t[j] = '1';
                if (check_element(t)) {
                    ans[j] = ind;
                    break;
                }
                t[j] = '0';
            }
        }
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

messy.cpp: In function 'void comp(std::string&, std::vector<int>&)':
messy.cpp:12:23: error: 'n' was not declared in this scope
   12 |     string b = string(n, '0');
      |                       ^
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
      |         ^~~~