Submission #235580

#TimeUsernameProblemLanguageResultExecution timeMemory
235580DavidDamianParrots (IOI11_parrots)C++11
17 / 100
12 ms1536 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; for(int i=0;i<N;i++){ for(int bit=0;bit<8;bit++){ if(M[i]&(1<<bit)) bits[idx+bit]=1; } idx+=8; } for(int i=0;i<8*N;i+=2){ int number=bits[i]; number+=((bits[i+1])<<1); while(number--){ send(i/2); } } } }
#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); for(int i=0;i<L;i++){ 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; } 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...