제출 #681906

#제출 시각아이디문제언어결과실행 시간메모리
681906cadmiumskyUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" #define all(x) (x).begin(),(x).end() using namespace std; #define sz(x) (int)(x).size() void divide_in(int l, int r, string hint) { if(l == r) return; int mid = l + r >> 1; for(int i = l; i <= mid; i++) { hint[i] = '1'; add_element(hint); hint[i] = '0'; } for(int i = l; i <= mid; i++) hint[i] = '1'; divide_in(mid + 1, r, hint); for(int i = l; i <= mid; i++) hint[i] = '0', hint[i - l + mid + 1] = '1'; divide_in(l, mid, hint); } vector<int> rez; void divide_out(int l, int r, string hint) { //cerr << l << ' ' << r << ' ' << hint << '\n'; if(l == r) { for(int i = 0; i < sz(hint); i++) if(hint[i] == '0') { rez[l] = i; return; } assert(false); } int mid = l + r >> 1; vector<int> lf, rh; for(int i = 0; i < sz(hint); i++) { if(hint[i] == '1') continue; hint[i] = '1'; if(check_element(hint)) //cerr << "L " << hint << '\n', lf.emplace_back(i); else //cerr << "R " << hint << '\n', rh.emplace_back(i); hint[i] = '0'; } for(auto x : rh) hint[x] = '1'; divide_out(l, mid, hint); for(auto x : rh) hint[x] = '0'; for(auto x : lf) hint[x] = '1'; divide_out(mid + 1, r, hint); } vector<int> restore_permutation(int n, int w, int r) { rez.resize(n); string hint; hint.resize(n); fill(all(hint), '0'); divide_in(0, n - 1, hint); compile_set(); divide_out(0, n - 1, hint); vector<int> inv(n); for(int i = 0; i < sz(rez); i++) inv[rez[i]] = i; return inv; }

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

messy.cpp: In function 'void divide_in(int, int, std::string)':
messy.cpp:12:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |   int mid = l + r >> 1;
      |             ~~^~~
messy.cpp: In function 'void divide_out(int, int, std::string)':
messy.cpp:44:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   44 |   int mid = 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...