Submission #386924

#TimeUsernameProblemLanguageResultExecution timeMemory
386924godwindParrots (IOI11_parrots)C++17
17 / 100
3 ms1332 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> #include <algorithm> 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 == 10) { for (int i = 0; i < n; ++i) { is[i] = (mask >> i) & 1; } } else { int least = 0; if (cn > 10) { least = cn - 10; } else { least = cn; } for (int it = 0; it < least; ++it) { proceed(mask); } } } for (int i = 0; i < n; ++i) { if (parts[i].size() != 2) { exit(-1); } 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]); } }
#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...