Submission #50691

#TimeUsernameProblemLanguageResultExecution timeMemory
50691Mamnoon_SiamUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms640 KiB
#include "messy.h" //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; #define debug(s) cout<< #s <<" = "<< s <<endl #define all(v) (v).begin(), (v).end() #define KeepUnique(v) (v).erase( unique(all(v)), v.end() ) #define MEMSET(a,val) memset(a, val, sizeof a) #define PB push_back #define endl '\n' inline int myrand(int l, int r) { int ret = rand(); ret <<= 15; ret ^= rand(); if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l; return ret; } template <typename F, typename S> ostream& operator << (ostream& os, const pair< F, S>& p) { return os<<"(" <<p.first<<", "<<p.second<<")"; } typedef pair<int, int> ii; template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T> >; //int dx[] = {-1, +0, +1, +0}; //int dy[] = {+0, +1, +0, -1}; int n; vector<int> ans; void add(int b, int e) { if(b == e) return; string s(n, '1'); int mid = b + e >> 1; for(int i = b; i <= e; i++) s[i] = '0'; for(int i = b; i <= e; i++) s[i] = '0'; for(int i = b; i <= (b + e) / 2; i++) { s[i] = '1', add_element(s), s[i] = '0'; } add(b, mid), add(mid + 1, e); } void solve(int b, int e, vector<int> sub) { if(b == e) assert(sub.size() == 1); if(b == e) return void(ans[sub[0]] = b); int mid = b + e >> 1; string s(n, '1'); for(int i : sub) s[i] = '0'; vector<int> subleft, subright; for(int i : sub) { s[i] = '1'; if(check_element(s)) subleft.push_back(i); else subright.push_back(i); s[i] = '0'; } solve(b, mid, subleft), solve(mid + 1, e, subright); } vector<int> inverse(vector<int> p) { vector<int> tmp(p.size()); for(int i = 0; i < p.size(); i++) { tmp[i] = p[p[i]]; } return tmp; } vector<int> restore_permutation(int N, int w, int r) { n = N; ans.resize(n); add(0, n - 1); compile_set(); vector<int> tmp; for(int i = 0; i < n; i++) tmp.push_back(i); solve(0, n - 1, tmp); return ans; }

Compilation message (stderr)

messy.cpp: In function 'int myrand(int, int)':
messy.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
  ^~
messy.cpp:17:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
                          ^~~
messy.cpp: In function 'void add(int, int)':
messy.cpp:37:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = b + e >> 1;
            ~~^~~
messy.cpp: In function 'void solve(int, int, std::vector<int>)':
messy.cpp:48:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = b + e >> 1;
            ~~^~~
messy.cpp: In function 'std::vector<int> inverse(std::vector<int>)':
messy.cpp:63:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < p.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...