Submission #573465

#TimeUsernameProblemLanguageResultExecution timeMemory
573465DeepessonParrots (IOI11_parrots)C++17
0 / 100
6 ms1216 KiB
/**Encoder**/ #include <bits/stdc++.h> #include "encoder.h" #include "encoderlib.h" void send(int a); std::string enviar; int qtdzeros,qtduns; void inserezero(void){ if(!qtdzeros)assert(0); --qtdzeros; enviar+="0"; } void insereum(void){ if(!qtduns)assert(0); --qtduns; enviar+="1"; } std::string plano; void codificar_e_enviar(){ int count=0; for(auto&x:enviar)if(x=='1')++count; if(count){ while(enviar.size()&&enviar.back()=='0'){ enviar.pop_back(); } if(enviar.size())enviar.pop_back(); } //std::cout<<enviar<<" envia\n"; int cur=0; count=0; for(auto&x:enviar){ if(x=='1'){ ++cur; }else {send(cur);++count;} } } void encode(int N, int M[]) { qtduns=256; qtdzeros=N*9; enviar=""; plano=""; int count = 0; for(int i=0;i!=N;++i){ for(int j=0;j!=8;++j){ bool valor = (bool)((M[i]^53)&(1<<j)); count+=valor; plano.push_back(valor+48); } } if(count>256){ insereum(); }else inserezero(); for(int i=0;i!=plano.size();++i){ bool valor = plano[i]-48; if(count>256){ valor=!valor; } if(valor)insereum();else inserezero(); } codificar_e_enviar(); }
/**Decoder**/ #include <bits/stdc++.h> #include "decoder.h" #include "decoderlib.h" void output(int b); void decode(int N, int L, int X[]) { int count[256]={}; for(int i=0; i<L; i++) { count[X[i]]++; } std::string trueseq; int cur=0; while(cur!=256){ if(count[cur]){ --count[cur]; trueseq.push_back('0'); }else { ++cur; trueseq.push_back('1'); } } trueseq+="1"; for(int i=0;i!=500;++i)trueseq+="0"; // std::cout<<"Recebe "<<trueseq<<"\n"; cur=1; bool inverte = trueseq[0]-48; for(int i=0;i!=N;++i){ int ans=0; for(int j=0;j!=8;++j){ int p = (1<<j); bool k = trueseq[cur]-48; if(inverte)k=!k; if(k)ans+=p; ++cur; } assert(ans<256); output(ans^53); } }

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i!=plano.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...