Submission #772955

#TimeUsernameProblemLanguageResultExecution timeMemory
772955PoonYaPatParrots (IOI11_parrots)C++14
81 / 100
4 ms1304 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; vector<int> v; void put(int x) { for (int i=0; i<8; ++i) { if (x&(1<<i)) v.push_back(1); else v.push_back(0); } } void encode(int N, int M[]) { v.clear(); for (int i=0; i<N; ++i) put(M[i]); for (int i=0; i+1<v.size(); i+=2) { //consider bit i and i+1 if (v[i]==v[i+1]) send(i+v[i]); else { send(i); if (v[i]==0) send(i); else send(i+1); } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; vector<int> ans,group[128]; void decode(int N, int len, int X[]) { ans.clear(); for (int i=0; i<128; ++i) group[i].clear(); for (int i=0; i<len; ++i) group[X[i]/2].push_back(X[i]%2); for (int i=0; i<128; ++i) { if (group[i].size()==0) break; if (group[i].size()==1) { ans.push_back(group[i][0]); ans.push_back(group[i][0]); } else { if (group[i][0]==group[i][1]) { ans.push_back(0); ans.push_back(1); } else { ans.push_back(1); ans.push_back(0); } } } for (int i=0; i+7<ans.size(); i+=8) { int res=0,mul=1; for (int j=0; j<8; ++j) { if (ans[i+j]==1) res+=mul; mul*=2; } output(res); } }

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for (int i=0; i+1<v.size(); i+=2) {
      |                 ~~~^~~~~~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for (int i=0; i+7<ans.size(); i+=8) {
      |                 ~~~^~~~~~~~~~~
#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...