Submission #66018

#TimeUsernameProblemLanguageResultExecution timeMemory
66018llllilllParrots (IOI11_parrots)C++14
98 / 100
13 ms2440 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; void encode(int N, int M[]) { int forward_cnt = 0, backward_cnt = 0; vector<int> forward, backward; for (int i = 0; i < N; i++) { int msg = 0; msg += (i << 2); int tmp = M[i]; for (int j = 3; j >= 0; j--) { int cnt = tmp % 4; for (int k = 1; k <= cnt; k++) { forward.push_back(msg + j); forward_cnt++; } cnt ^= 3; for (int k = 1; k <= cnt; k++) { backward.push_back(msg + j); backward_cnt++; } tmp >>= 2; } } if (backward_cnt < forward_cnt) { for (int i = 0; i < backward_cnt; i++) send(backward[i]); for (int i = 0; i < 4; i++) send(255); } else { for (int i = 0; i < forward_cnt; i++) send(forward[i]); } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; void decode(int N, int L, int X[]) { int origin[64]; int back_cnt = 0; for (int i = 0; i < L; i++) { if (X[i] == 255) back_cnt++; } if (back_cnt >= 4) { for (int i = 0; i < N; i++) origin[i] = 255; int cnt = 0; for (int i = 0; i < L; i++) { if (cnt == 4) break; if (X[i] == 255) { X[i] = -1; cnt++; } } for (int i = 0; i < L; i++) { if (X[i] == -1) continue; int idx = X[i] >> 2; int idx_inner = X[i] % 4; origin[idx] -= 1 << ((3 - idx_inner) * 2); } } else { for (int i = 0; i < N; i++) origin[i] = 0; for (int i = 0; i < L; i++) { int idx = X[i] >> 2; int idx_inner = X[i] % 4; origin[idx] += 1 << ((3 - idx_inner) * 2); } } for (int i = 0; i < N; i++) { output(origin[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...