제출 #45422

#제출 시각아이디문제언어결과실행 시간메모리
45422smu201111192앵무새 (IOI11_parrots)C++17
96 / 100
12 ms2432 KiB
#include "encoder.h" #include "encoderlib.h" int min(int u,int v){ return u < v ? u : v; } int cnt[4]; void encode(int N, int M[]) { int d = min(32,N); for(int i = 0; i < 4; i++) cnt[i] = 0; for(int i = 0; i < d; i++){ for(int j = 0; j < 8; j++){ if(i + 32 < N){ int bit1 = ((M[i] & (1<<j)) > 0); int bit2 = ((M[i+32] & (1<<j)) > 0); if(bit1 == 0 && bit2 == 0) cnt[0]++; if(bit1 == 1 && bit2 == 1) cnt[3]++; } } } int rev = (cnt[3] > cnt[0]); if(N<=32) rev = 0; for(int i = 0; i < d; i++){ for(int j = 0; j < 8; j++){ int bit1 = ((M[i] & (1<<j)) > 0); int bit2 = - 1; if(i + 32 < N) bit2 = ((M[i+32] & (1<<j)) > 0); if( bit1 == bit2 ){ if(rev && bit1 == 0 && bit2 == 0){ send(i*8+j); send(i*8+j); send(i*8+j); } if(!rev&&bit1 == 1 && bit2 == 1){ send(i*8+j); send(i*8+j); send(i*8+j); } } else{ if(bit1 == 1) send(i*8+j); if(bit2 == 1) { send(i*8+j);send(i*8+j);} } } } if(rev) { send(255) ,send(255) , send(255), send(255); } }
#include "decoder.h" #include "decoderlib.h" int ccnt[256]; int ans[65]; void decode(int N, int L, int X[]) { for(int i = 0; i < 65; i++) ans[i] = 0; for(int i = 0; i < 256; i++) ccnt[i] = 0; for(int i = 0; i < L; i++){ ccnt[X[i]]++; } int rev = 0; if(ccnt[255] >= 4){ rev = 1; ccnt[255] -= 4; } for(int i = 0; i < 256; i++){ int piv = i / 8; int add = i % 8; if(ccnt[i] == 0 && piv + 32 >= N) continue; if(ccnt[i] == 0){ if(rev) { ans[piv] |= (1<<add); ans[piv+32] |= (1<<add); } } else if(ccnt[i] == 1 ){ ans[piv] |= (1<<add); } else if(ccnt[i] == 2){ ans[piv+32] |= (1<<add); } else if(ccnt[i] == 3){ if(!rev) { ans[piv] |= (1<<add); ans[piv+32] |= (1<<add); } } } 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...