제출 #1054654

#제출 시각아이디문제언어결과실행 시간메모리
1054654thieunguyenhuyUnscrambling a Messy Bug (IOI16_messy)C++17
20 / 100
1 ms604 KiB
#ifndef hwe #include "messy.h" #endif #include <bits/stdc++.h> using namespace std; #define popcount(n) (__builtin_popcountll((n))) #define clz(n) (__builtin_clzll((n))) #define ctz(n) (__builtin_ctzll((n))) #define lg(n) (63 - __builtin_clzll((n))) #define BIT(n, i) (((n) >> (i)) & 1ll) #define MASK(i) (1ll << (i)) #define FLIP(n, i) ((n) ^ (1ll << (i))) #define ON(n, i) ((n) | MASK(i)) #define OFF(n, i) ((n) & ~MASK(i)) #define Int __int128 #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long long, int> pli; typedef pair<int, long long> pil; typedef vector<pair<int, int>> vii; typedef vector<pair<long long, long long>> vll; typedef vector<pair<long long, int>> vli; typedef vector<pair<int, long long>> vil; template <class T1, class T2> bool maximize(T1 &x, T2 y) { if (x < y) { x = y; return true; } return false; } template <class T1, class T2> bool minimize(T1 &x, T2 y) { if (x > y) { x = y; return true; } return false; } template <class T> void remove_duplicate(vector<T> &ve) { sort (ve.begin(), ve.end()); ve.resize(unique(ve.begin(), ve.end()) - ve.begin()); } mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); template <class T> T random(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } template <class T> T random(T r) { return rng() % r; } const int N = 1e6 + 5; const int MOD = 1e9 + 7; const int inf = 1e9; const ll INF = 1e18; int n, w, r, write_counter = 0, read_counter = 0; vector<int> ans, p; set<string> S; #ifdef hwe void add_element(string a) { cerr << "Add: " << a << '\n'; S.emplace(a); } void compile_set() { set<string> new_set; for (auto num : S) { string new_num(num.size(), '0'); for (int i = 0; i < n; ++i) new_num[i] = num[p[i]]; new_set.emplace(new_num); } S = new_set; } bool check_element(string x) { cerr << "Check: " << x << '\n'; return S.find(x) != S.end(); } #endif void add(int l, int r, string s) { if (l == r) return; int mid = l + r >> 1; for (int i = l; i <= mid; ++i) { assert(++write_counter <= 896); s[i] = '1'; add_element(s); s[i] = '0'; } string le = s, ri = s; for (int i = mid + 1; i <= r; ++i) le[i] = '1'; for (int i = l; i <= mid; ++i) ri[i] = '1'; add(l, mid, le); add(mid + 1, r, ri); } void check(int l, int r, string s) { if (l == r) { int before = ans.size(); for (int i = 0; i < s.size(); ++i) { if (s[i] == '0') ans.emplace_back(i); } assert(ans.size() == before + 1); return; } int mid = l + r >> 1; string le = s, ri = s; for (int i = 0; i < s.size(); ++i) { if (s[i] == '1') continue; assert(++read_counter <= 896); s[i] = '1'; bool flag = check_element(s); s[i] = '0'; if (flag) le[i] = '0', ri[i] = '1'; else le[i] = '1', ri[i] = '0'; } check(l, mid, le); check(mid + 1, r, ri); } vector<int> restore_permutation(int _n, int _w, int _r) { n = _n, w = _w, r = _r; write_counter = read_counter = 0; ans.clear(); ans.reserve(n); add(0, n - 1, string(n, '0')); compile_set(); check(0, n - 1, string(n, '0')); return ans; } #ifdef hwe signed main() { cin >> n; p.resize(n); for (auto &x : p) cin >> x; vector<int> perm = restore_permutation(n, 0, 0); for (auto &x : perm) cerr << x << ' '; cerr << '\n'; return 0; } #endif

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

messy.cpp: In function 'void add(int, int, std::string)':
messy.cpp:97:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   97 |  int mid = l + r >> 1;
      |            ~~^~~
messy.cpp: In function 'void check(int, int, std::string)':
messy.cpp:115:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  115 |   for (int i = 0; i < s.size(); ++i) {
      |                   ~~^~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from messy.cpp:5:
messy.cpp:118:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  118 |   assert(ans.size() == before + 1);
      |          ~~~~~~~~~~~^~~~~~~~~~~~~
messy.cpp:122:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  122 |  int mid = l + r >> 1;
      |            ~~^~~
messy.cpp:125:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  125 |  for (int i = 0; i < s.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...