Submission #754194

#TimeUsernameProblemLanguageResultExecution timeMemory
754194lukameladzeParrots (IOI11_parrots)C++14
88 / 100
10 ms1520 KiB
#include "encoder.h" #include "encoderlib.h" # include <bits/stdc++.h> using namespace std; # define pb push_back void encode(int N, int M[]) { if (N <= 32) { int id = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < 8; j++) { if ((1<<j)&M[i]) { //cout<<"send "<<i<<" "<<j<<" "<<id<<"\n"; send(id); } id++; } } } else { vector <int> v; for (int i = 0; i < N; i++) { for (int j = 0; j < 8; j++) { if ((1<<j)&M[i]) { v.pb(1); } else v.pb(0); } } for (int i = 0; i < v.size(); i+=2) { if (v[i] == 0 && v[i + 1] == 0) { continue; } if (v[i] == 0 && v[i + 1] == 1) { send(i / 2); continue; } if (v[i] == 1 && v[i + 1] == 0) { send(i / 2); send(i / 2); continue; } if (v[i] == 1 && v[i + 1] == 1) { send(i / 2); send(i / 2); send(i / 2); continue; } } } }
#include "decoder.h" #include "decoderlib.h" # include <bits/stdc++.h> using namespace std; # define pb push_back const int MX = 1e4 + 5; void decode(int N, int L, int X[]) { vector <int> ans, x, cnt; ans = vector <int>(MX, 0); x = vector <int> (MX, 0); cnt = vector <int> (MX, 0); for (int i = 0; i < L; i++) x[i] = X[i]; //cout<<"received "; //for (int i = 0; i < L; i++) cout<<x[i]<<" "; //cout<<"\n"; if (N <= 32) { for (int i = 0; i < L; i++) { int id = x[i]; ans[id / 8] += (1<<(id % 8)); } for (int i = 0; i < N; i++) { output(ans[i]); } return ; } for (int i = 0; i < L; i++) { cnt[x[i]]++; } vector <int> v; for (int i = 0; i < 4 * N; i++) { if (cnt[i] == 0) v.pb(0), v.pb(0); else if (cnt[i] == 1) v.pb(0), v.pb(1); else if (cnt[i] == 2) v.pb(1), v.pb(0); else if (cnt[i] == 3) v.pb(1), v.pb(1); } int id = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < 8; j++) { if (v[id] == 1) ans[i] += (1<<j); id++; } } for (int i = 0; i < N; i++) { output(ans[i]); } }

Compilation message (stderr)

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