Submission #690944

#TimeUsernameProblemLanguageResultExecution timeMemory
690944NemanjaSo2005Unscrambling a Messy Bug (IOI16_messy)C++14
70 / 100
1 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" #define ll long long using namespace std; int N,niz[130],stepen[10],gde[130]; bool locked[130]; string ps; vector<int> ret,poz; void add(){ stepen[0]=1; for(int i=1;i<=7;i++) stepen[i]=stepen[i-1]*2; ps=""; for(int i=1;i<=N;i++) ps.push_back('1'); for(int i=1;i<=7;i++){ ps[i-1]='0'; add_element(ps); } for(int i=0;i<N;i++) niz[i]=i; for(int it=0;stepen[it]<N;it++){ for(int i=0;i<ps.size();i++) ps[i]='0'; for(int i=0;i<it;i++) ps[i]='1'; for(int i=it;i<N;i++) if(i&stepen[it]){ ps[i]='1'; add_element(ps); ps[i]='0'; } } return; } void read(){ ret.resize(N); for(int it=0;stepen[it]<N;it++){ ///Trazi gde je it-1 if(it!=0){ int traz=0; for(int j=0;j<it;j++) if((it-1)&stepen[j]) traz+=stepen[j]; for(int i=0;i<N;i++) ps[i]='1'; for(int i=0;i<poz.size();i++) ps[poz[i]]='0'; for(int i=0;i<N;i++){ if(locked[i]) continue; if(gde[i]!=traz) continue; ps[i]='0'; if(check_element(ps)){ locked[i]=true; gde[i]=it-1; poz.push_back(i); break; } else ps[i]='1'; } } for(int i=0;i<N;i++) ps[i]='0'; for(int i=0;i<poz.size();i++) ps[poz[i]]='1'; for(int i=0;i<N;i++){ if(locked[i]) continue; ps[i]='1'; if(check_element(ps)) gde[i]+=stepen[it]; ps[i]='0'; } } for(int i=0;i<N;i++) ret[i]=gde[i]; } vector<int> restore_permutation(int n, int w, int r) { N=n; add(); compile_set(); read(); return ret; }

Compilation message (stderr)

messy.cpp: In function 'void add()':
messy.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |       for(int i=0;i<ps.size();i++)
      |                   ~^~~~~~~~~~
messy.cpp: In function 'void read()':
messy.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |          for(int i=0;i<poz.size();i++)
      |                      ~^~~~~~~~~~~
messy.cpp:68:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |       for(int i=0;i<poz.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...