제출 #1071628

#제출 시각아이디문제언어결과실행 시간메모리
1071628mc061Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms856 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(); const int N = 128; int sz; bitset<N> corresponds[N]; bool query(const bitset<N>& qq) { string s; for (int i = 0; i < sz; ++i) { if (qq[i]) { s += "1"; } else { s += "0"; } } return check_element(s); } void add(const bitset<N>& qq) { string s; for (int i = 0; i < sz; ++i) { if (qq[i]) { s += "1"; } else { s += "0"; } } add_element(s); } void get_els(int l, int r) { if (l == r) return; bitset<N> cur_query; for (int i = 0; i < sz; ++i) { if (i > r || i < l) cur_query[i] = 1; } int m = (l + r) / 2; get_els(l, m); get_els(m + 1, r); for (int i = l; i <= m; ++i) { cur_query[i] = 1; add(cur_query); cur_query[i] = 0; } } void solve(int l, int r) { if (l == r) return; bitset<N> cur_query; vector<int> tot_bits; vector<int> one_bits; for (int i = 0; i < sz; ++i) { if (!(l <= i && i <= r)) cur_query |= corresponds[i]; } int m = (l+r)/2; for (int i = 0; i < sz; ++i) { if (!cur_query[i]) tot_bits.push_back(i); } vector<int> ans(tot_bits.size(), 0); int tot = 0; for (int i = 0; i+1 < tot_bits.size(); ++i) { cur_query[tot_bits[i]] = 1; int ret = query(cur_query); ans[i] = ret; tot += ret; cur_query[tot_bits[i]] = 0; } if (tot != (r-l+1)/2) ans[tot_bits.size()-1] = 1; bitset<N> corr0, corr1; for (int i = 0; i < tot_bits.size(); ++i) { if (ans[i] == 0) { corr0[tot_bits[i]] = 1; } else { corr1[tot_bits[i]] = 1; } } for (int i = l; i <= m; ++i) { corresponds[i] = corr1; } for (int i = m+1; i <= r; ++i) { corresponds[i] = corr0; } solve(l, m); solve(m+1, r); } std::vector<int> restore_permutation(int n, int w, int r) { sz = n; get_els(0, n-1); compile_set(); solve(0, n-1); vector<int> ret(n); for (int i = 0; i < n; ++i) { int s = corresponds[i]._Find_first(); ret[s] = i; } return ret; }

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

messy.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
messy.cpp: In function 'void solve(int, int)':
messy.cpp:67:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for (int i = 0; i+1 < tot_bits.size(); ++i) {
      |                     ~~~~^~~~~~~~~~~~~~~~~
messy.cpp:78:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for (int i = 0; i < tot_bits.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...