제출 #45397

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