Submission #1196042

#TimeUsernameProblemLanguageResultExecution timeMemory
1196042lrnnzUnscrambling a Messy Bug (IOI16_messy)C++17
38 / 100
1 ms328 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include "messy.h" using namespace std; #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() #define ll long long #define ld long double #define ui uint64_t #define cont(set, element) ((set).find(element) != (set).end()) /********* DEBUG *********/ template <typename T> void outvec(const vector<T>& Z){ for (const T& x : Z) cout << x << ' '; cout << "\n"; } void printVariable(const any& var) { if (!var.has_value()) { cout << "null"; return; } if (var.type() == typeid(int)) { cout << any_cast<int>(var); } else if (var.type() == typeid(double)) { cout << any_cast<double>(var); } else if (var.type() == typeid(float)) { cout << any_cast<float>(var); } else if (var.type() == typeid(char)) { cout << any_cast<char>(var); } else if (var.type() == typeid(bool)) { cout << (any_cast<bool>(var) ? "true" : "false"); } else if (var.type() == typeid(string)) { cout << any_cast<string>(var); } else if (var.type() == typeid(const char*)) { cout << any_cast<const char*>(var); } else if (var.type() == typeid(long long)) { cout << any_cast<long long>(var); } else { cout << "[unknown type]"; } } template<typename... Args> void outval(Args... args) { vector<any> variables = {args...}; for (size_t i = 0; i < variables.size(); ++i) { printVariable(variables[i]); if (i != variables.size() - 1) { cout << " "; } } cout << "\n"; } #define nl "\n" #define sp << " " << /********* DEBUG *********/ const ll MOD = 1000000007; const ll inf = 1e18; const ll mxN = 1000005; ll _r=0,_w=0; vector<int> restore_permutation(int n, int w, int r) { // st1, and also 2. w writes, r^2 reads for (int i = 0; i < n; i++){ string make = ""; for (int j = 0; j < n; j++){ make+= (j<=i ? '1' : '0'); } add_element(make); //outval("add:",make); assert(++_w <= w); } compile_set(); // creating vector<char> curr(n, '0'); vector<int> ans(n); for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ if (curr[j] != '0') continue; string st = ""; for (int k = 0; k < n; k++){ if (k == j) st+='1'; else st+=curr[k]; } //outval("curr:",st); assert(++_r <= r); if (check_element(st)){ curr[j]='1'; ans[j]=i; break; } } } return ans; }

Compilation message (stderr)

In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from messy.cpp:1:
In function 'typename __gnu_cxx::__enable_if<std::__is_byte<_Tp>::__value, void>::__type std::__fill_a1(_Tp*, _Tp*, const _Tp&) [with _Tp = char]',
    inlined from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = char*; _Tp = char]' at /usr/include/c++/11/bits/stl_algobase.h:969:21,
    inlined from '_OutputIterator std::__fill_n_a(_OutputIterator, _Size, const _Tp&, std::random_access_iterator_tag) [with _OutputIterator = char*; _Size = long unsigned int; _Tp = char]' at /usr/include/c++/11/bits/stl_algobase.h:1120:20,
    inlined from '_OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = char*; _Size = long unsigned int; _Tp = char]' at /usr/include/c++/11/bits/stl_algobase.h:1149:29,
    inlined from 'static _ForwardIterator std::__uninitialized_fill_n<true>::__uninit_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = char*; _Size = long unsigned int; _Tp = char]' at /usr/include/c++/11/bits/stl_uninitialized.h:255:29,
    inlined from '_ForwardIterator std::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = char*; _Size = long unsigned int; _Tp = char]' at /usr/include/c++/11/bits/stl_uninitialized.h:297:17,
    inlined from '_ForwardIterator std::__uninitialized_fill_n_a(_ForwardIterator, _Size, const _Tp&, std::allocator<_Tp2>&) [with _ForwardIterator = char*; _Size = long unsigned int; _Tp = char; _Tp2 = char]' at /usr/include/c++/11/bits/stl_uninitialized.h:410:39,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_fill_initialize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = char; _Alloc = std::allocator<char>]' at /usr/include/c++/11/bits/stl_vector.h:1596:33,
    inlined from 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = char; _Alloc = std::allocator<char>]' at /usr/include/c++/11/bits/stl_vector.h:525:27,
    inlined from 'std::vector<int> restore_permutation(int, int, int)' at messy.cpp:91:29:
/usr/include/c++/11/bits/stl_algobase.h:944:25: warning: 'void* __builtin_memset(void*, int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
  944 |         __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len);
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
      |         ^~~~
#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...