제출 #235589

#제출 시각아이디문제언어결과실행 시간메모리
235589DavidDamian앵무새 (IOI11_parrots)C++11
81 / 100
14 ms1792 KiB
#include "encoder.h" #include "encoderlib.h" #include<bits/stdc++.h> using namespace std; void encode(int N, int M[]) { if(N<=32){ int idx=0; for(int i=0;i<N;i++){ for(int bit=0;bit<8;bit++){ if(M[i]&(1<<bit)) send(idx+bit); } idx+=8; } } else{ vector<int> bits(8*N,0); int idx=0; int sum=0; for(int i=0;i<N;i++){ for(int bit=0;bit<8;bit++){ if(M[i]&(1<<bit)) bits[idx+bit]=1,sum++; } idx+=8; } int scheme=(sum<=N/2)? 1 : 0; for(int i=0;i<8*N;i+=2){ int number=bits[i]; number+=((bits[i+1])<<1); if(scheme==0) number=3-number; while(number--){ send(i/2); } } if(scheme==0){ send(0); send(0); send(0); send(0); } } }
#include "decoder.h" #include "decoderlib.h" #include<bits/stdc++.h> using namespace std; void decode(int N, int L, int X[]) { if(N<=32){ vector<int> binary(8*N,0); sort(X,X+L); for(int i=0;i<L;i++){ binary[X[i]]=1; } for(int i=0;i<8*N;i+=8){ int number=0; for(int bit=0;bit<8;bit++){ if(binary[i+bit]) number+=(1<<bit); } output(number); } } else{ vector<int> binary(8*N,0); sort(X,X+L); int scheme=(X[3]==0)? 0 : 1; for(int i=0;i<L;i++){ if(scheme==0 && i<4) continue; int cnt=1; while(i<L-1 && X[i]==X[i+1]) i++,cnt++; if(cnt%2==1) binary[ 2*X[i] ]=1; if(cnt>=2) binary[ 2*X[i]+1 ]=1; } if(scheme==0){ for(int i=0;i<8*N;i++){ binary[i]=(binary[i])? 0 : 1; } } for(int i=0;i<8*N;i+=8){ int number=0; for(int bit=0;bit<8;bit++){ if(binary[i+bit]) number+=(1<<bit); } output(number); } } }
#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...