Submission #386916

#TimeUsernameProblemLanguageResultExecution timeMemory
386916godwindParrots (IOI11_parrots)C++17
Compilation error
0 ms0 KiB
#include "encoder.h" #include "encoderlib.h" #include <vector> using namespace std; void encode(int n, int M[]) { vector<int> is(n); for (int i = 0; i < n; ++i) { int FIRST = M[i] / 16; int SECOND = M[i] % 16; send(FIRST * 16 + i); send(SECOND * 16 + i); if (FIRST < SECOND) { is[i] = false; } else { is[i] = true; } } int mask = 0; for (int i = 0; i < n; ++i) { if (is[i]) { mask += (1 << i); } } for (int it = 0; it < 10; ++it) { send(mask); } }
#include "decoder.h" #include "decoderlib.h" #include <vector> #include <map> using namespace std; void decode(int n, int L, int X[]) { vector<int> ans(n), is(n); vector< vector<int> > parts(n); map<int, int> cnt; for (int i = 0; i < L; ++i) { ++cnt[X[i]]; } auto proceed = [&] (int mask) { int FP = mask / 16; int SP = mask % 16; int id = SP; parts[id].push_back(FP); }; for (auto P : cnt) { int mask = P.first; int cn = p.second; if (cn == 1) { proceed(mask); } else { if (cn == 10) { for (int i = 0; i < n; ++i) { is[i] = (mask >> i) & 1; } } else { proceed(mask); } } } for (int i = 0; i < n; ++i) { sort(parts[i].begin(), parts[i].end()); if (is[i]) { ans[i] = parts[i][1] * 16 + parts[i][0]; } else { ans[i] = parts[i][0] * 16 + parts[i][1]; } } for (int i = 0; i < n; ++i) { output(ans[i]); } }

Compilation message (stderr)

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:30:12: error: 'p' was not declared in this scope
   30 |   int cn = p.second;
      |            ^
decoder.cpp:46:3: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   46 |   sort(parts[i].begin(), parts[i].end());
      |   ^~~~
      |   qsort