제출 #386945

#제출 시각아이디문제언어결과실행 시간메모리
386945godwind앵무새 (IOI11_parrots)C++14
34 / 100
3 ms1332 KiB
#include "encoder.h" #include "encoderlib.h" #include <vector> #include <map> #include <algorithm> using namespace std; void encode(int n, int M[]) { vector<int> is(n); for (int i = 0; i < n; ++i) { if (M[i] > 255) { exit(-1); } int FIRST = M[i] / 16; int SECOND = M[i] % 16; if (FIRST >= 16 || SECOND >= 16) { exit(-1); } 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; for (int i = 0; i < n; ++i) { is[i] = (mask >> i) & 1; } } 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...