제출 #352042

#제출 시각아이디문제언어결과실행 시간메모리
352042tengiz05앵무새 (IOI11_parrots)C++17
99 / 100
8 ms1584 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; int A[100]; void encode(int n, int aa[]){ for(int i=0;i<n;i++)A[i] = aa[i]; int best_xor = 0; for(int j=0;j<8;j++){ int cnt = 0; for(int i=0;i<n;i++){ cnt += (A[i]>>j&1); }if(cnt > n/2)best_xor |= (1<<j); } send(best_xor); send(best_xor); send(best_xor); send(best_xor); for(int i=0;i<n;i++)A[i] ^= best_xor; for(int i=0;i<n;i++){ while(A[i] >= 64){ A[i] -= 64; send(i | (3<<6)); } while(A[i] >= 16){ A[i] -= 16; send(i | (2<<6)); } while(A[i] >= 4){ A[i] -= 4; send(i | (1<<6)); } while(A[i] >= 1){ A[i] -= 1; send(i | (0<<6)); } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; int a[256], cnt[256]; void decode(int n, int len, int x[]){ for(int i=0;i<256;i++)a[i]=0,cnt[i]=0; for(int i=0;i<len;i++)cnt[x[i]]++; int best_xor=0; for(int i=0;i<256;i++){ if(cnt[i] > 3){ cnt[i] -= 4; best_xor = i; break; } } for(int i=0;i<len;i++){ if(!cnt[x[i]])continue; int type = (x[i] & 192)>>6; int ind = x[i] & 63; if(type == 3)a[ind] += 64,cnt[x[i]]--; if(!cnt[x[i]])continue; if(type == 2)a[ind] += 16,cnt[x[i]]--; if(!cnt[x[i]])continue; if(type == 1)a[ind] += 4,cnt[x[i]]--; if(!cnt[x[i]])continue; if(type == 0)a[ind] += 1,cnt[x[i]]--; if(!cnt[x[i]])continue; } for(int i=0;i<n;i++)output(a[i]^best_xor); }
#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...