제출 #1071454

#제출 시각아이디문제언어결과실행 시간메모리
1071454mc061Unscrambling a Messy Bug (IOI16_messy)C++14
49 / 100
1 ms356 KiB
#pragma once

#include <bits/stdc++.h>
using namespace std;
void add_element(std::string x);
bool check_element(std::string x);
void compile_set();

std::vector<int> restore_permutation(int n, int w, int r) {
    srand(123123);
    string s(n, '0');
    for (int i = 0; i < n-1; ++i) {
        s[i] = '1';
        add_element(s);
    }
    compile_set();

    vector<pair<int, int>> know;
    vector<bool> busy(n, false);

    int c = 0;
    for (int bits = 1; bits < n; ++bits) {
        string cur(n, '0');
        for (auto [was, now] : know) {
            cur[now] = '1';
        }

        vector<string> pot;
        for (int i = 0; i < n; ++i) {
            if (cur[i] == '1') continue;
            cur[i] = '1';
            pot.push_back(cur);
            cur[i] = '0';
        }
        random_shuffle(pot.begin(), pot.end());
        for (int i = 0; i < pot.size(); ++i) {
            // cerr << "ck ";
            // for (char c : pot[i]) cerr << c;
            // cerr << " : ";
            bool x;
            if (i == pot.size() - 1)
                x = true;
            else
                x = check_element(pot[i]);
            ++c;
            // cerr << x << endl;
            if (!x) continue;
            for (int j = 0; j < n; ++j) {
                if (pot[i][j] != '1' || busy[j]) continue;
                busy[j] = true;
                know.push_back({bits-1, j});
            }
            break;
        }
    }
    vector<int> perm(n, -1);
    for (auto [was, now] : know) {
        perm[now] = was;
    }
    for (int i = 0; i < n; ++i) {
        if (perm[i] == -1) perm[i] = n-1;
    }
    // cerr << c << endl;
    // cerr << endl;
    return perm;
}

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

messy.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:24:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |         for (auto [was, now] : know) {
      |                   ^
messy.cpp:36:27: 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]
   36 |         for (int i = 0; i < pot.size(); ++i) {
      |                         ~~^~~~~~~~~~~~
messy.cpp:41: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]
   41 |             if (i == pot.size() - 1)
      |                 ~~^~~~~~~~~~~~~~~~~
messy.cpp:57:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   57 |     for (auto [was, now] : know) {
      |               ^
#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...