제출 #66016

#제출 시각아이디문제언어결과실행 시간메모리
66016llllilll앵무새 (IOI11_parrots)C++14
81 / 100
14 ms2528 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; for (int i = 0; i < L; i++) { if (back_cnt > 3 && X[i] == 255) { back_cnt--; 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...