제출 #828306

#제출 시각아이디문제언어결과실행 시간메모리
828306caganyanmazUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #define pb push_back #include <vector> using namespace std; #ifdef DEBUGGING #include "../debug.h" #else #define debug(x...) void(42) #endif #include "messy.h" vector<int> p; static inline bool inv(vector<int>& v, int val) { auto it = lower_bound(v.begin(), v.end(), val); return it != v.end() && *it == val; } void add(int l, int r, string& s) { if (r - l == 1) return; int m = l+r>>1; for (int i = l; i < m; i++) { s[i] = '1'; debug(l, r, i, s.c_str()); add_element(s); s[i] = '0'; } for (int i = m; i < r; i++) s[i] = '1'; add(l, m, s); for (int i = 0; i < m; i++) s[i] = '1'; for (int i = m; i < r; i++) s[i] = '0'; add(m, r, s); } void find(int l, int r, string& s, vector<int>& cp) { if (r - l == 1) { assert(cp.size() == 1); p[cp[0]] = l; return; } vector<int> lp; for (int i : cp) { s[i] = '1'; if (check_element(s)) lp.pb(i); s[i] = '0'; } vector<int> rp; for (int i : cp) if (!inv(lp, i)) rp.pb(i); int m = l+r>>1; for (int i : rp) s[i] = '1'; find(l, m, s, lp); for (int i : lp) s[i] = '1'; for (int i : rp) s[i] = '0'; find(m, r, s, rp); for (int i : lp) s[i] = '0'; } vector<int> restore_permutation(int n, int w, int r) { string s(n, '0'); add(0, n, s); compile_set(); p = vector<int>(n); vector<int> cp(n); for (int i = 0; i < n; i++) cp[i] = i; for (int i : cp) s[i] = '0'; find(0, n, s, cp); return p; }

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

messy.cpp: In function 'void add(int, int, std::string&)':
messy.cpp:26:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |  int m = l+r>>1;
      |          ~^~
messy.cpp: In function 'void find(int, int, std::string&, std::vector<int>&)':
messy.cpp:64:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |  int m = l+r>>1;
      |          ~^~
#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...