제출 #573544

#제출 시각아이디문제언어결과실행 시간메모리
573544Deepesson앵무새 (IOI11_parrots)C++17
99 / 100
8 ms1356 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(){ //std::cout<<enviar<<" envia\n"; int cur=0; int 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]^145)&(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'); } } // 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; } output(ans^145); } }

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

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