Submission #411238

#TimeUsernameProblemLanguageResultExecution timeMemory
411238AugustinasJucasParrots (IOI11_parrots)C++14
98 / 100
11 ms1336 KiB
#include <bits/stdc++.h> using namespace std; #include "encoder.h" #include "encoderlib.h" void encode(int n, int M[]){ vector<int> vec; for(int i = 0; i < n; i++){ auto x = M[i]; for(int i = 7; i > -1; i--){ vec.push_back((bool)((1 << i) & x)); } } //cout << "vec: \n"; for(auto x : vec) cout << x << " "; cout << endl; vector<int> pos[2]; for(int i = 0; i < vec.size(); i += 2){ int st = vec[i] * 2 + vec[i+1]; for(int j = 0; j < st; j++) pos[0].push_back(i/2); for(int j = 0; j < 3-st; j++) pos[1].push_back(i/2); } for(int i = 0; i < 4; i++) pos[1].push_back(255); //cout << "darom 0: " << (pos[0].size() < pos[1].size()) << endl; if(pos[0].size() < pos[1].size()){ for(auto x : pos[0]) send(x); }else{ for(auto x : pos[1]) send(x); } }
#include <bits/stdc++.h> using namespace std; #include "decoder.h" #include "decoderlib.h" void decode(int n, int l, int X[]){ int kek[10000] = {}; for(int i = 0; i < l; i++) kek[X[i]]++; vector<bool> vec(8*n); for(int i = 0; i < 8*n; i += 2){ int st = kek[i/2]; if(st >= 4) st -= 4; if(kek[255] >= 4) st = 3 - st; vec[i] = (st & 2)/2; vec[i+1] = st & 1; } // cout << "gaunu vec: \n"; for(auto x : vec) cout << x << " "; cout << endl; for(int i =0; i < vec.size(); i += 8){ int st = 0; for(int j = 0; j < 8; j++) st += (int)vec[i+7-j] * (1 << j); // cout << "st: " << st << endl; output(st); } }

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:18:22: 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 < vec.size(); i += 2){
      |                    ~~^~~~~~~~~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i  =0; i < vec.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...