Submission #573451

#TimeUsernameProblemLanguageResultExecution timeMemory
573451Deepesson앵무새 (IOI11_parrots)C++17
Compilation error
0 ms0 KiB
/**Encoder**/ #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*5; enviar=""; plano=""; int count = 0; for(int i=0;i!=N;++i){ for(int j=0;j!=8;++j){ bool valor = (bool)(M[i]&(1<<j)); count+=valor; plano.push_back(valor+48); } } if(count>256){ enviar+="1"; }else enviar+="0"; for(int i=0;i!=plano.size();++i){ bool valor = plano[i]-48; if(count>256){ valor=!valor; } enviar+=valor+48; } codificar_e_enviar(); }
/**Decoder**/ #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); } }

Compilation message (stderr)

encoder.cpp:8:6: error: 'string' in namespace 'std' does not name a type
    8 | std::string enviar;
      |      ^~~~~~
encoder.cpp:5:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
    4 | #include "encoderlib.h"
  +++ |+#include <string>
    5 | 
encoder.cpp: In function 'void inserezero()':
encoder.cpp:12:18: error: 'assert' was not declared in this scope
   12 |     if(!qtdzeros)assert(0);
      |                  ^~~~~~
encoder.cpp:5:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    4 | #include "encoderlib.h"
  +++ |+#include <cassert>
    5 | 
encoder.cpp:14:5: error: 'enviar' was not declared in this scope
   14 |     enviar+="0";
      |     ^~~~~~
encoder.cpp: In function 'void insereum()':
encoder.cpp:18:16: error: 'assert' was not declared in this scope
   18 |     if(!qtduns)assert(0);
      |                ^~~~~~
encoder.cpp:18:16: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
encoder.cpp:20:5: error: 'enviar' was not declared in this scope
   20 |     enviar+="1";
      |     ^~~~~~
encoder.cpp: At global scope:
encoder.cpp:23:6: error: 'string' in namespace 'std' does not name a type
   23 | std::string plano;
      |      ^~~~~~
encoder.cpp:23:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
   23 | std::string plano;
      | ^~~
encoder.cpp: In function 'void codificar_e_enviar()':
encoder.cpp:29:16: error: 'enviar' was not declared in this scope
   29 |     for(auto&x:enviar){
      |                ^~~~~~
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:40:5: error: 'enviar' was not declared in this scope
   40 |     enviar="";
      |     ^~~~~~
encoder.cpp:41:5: error: 'plano' was not declared in this scope
   41 |     plano="";
      |     ^~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:12:10: error: 'string' is not a member of 'std'
   12 |     std::string trueseq;
      |          ^~~~~~
decoder.cpp:4:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
    3 | #include "decoderlib.h"
  +++ |+#include <string>
    4 | void output(int b);
decoder.cpp:17:13: error: 'trueseq' was not declared in this scope
   17 |             trueseq.push_back('0');
      |             ^~~~~~~
decoder.cpp:20:13: error: 'trueseq' was not declared in this scope
   20 |             trueseq.push_back('1');
      |             ^~~~~~~
decoder.cpp:25:20: error: 'trueseq' was not declared in this scope
   25 |     bool inverte = trueseq[0]-48;
      |                    ^~~~~~~