Submission #422881

#TimeUsernameProblemLanguageResultExecution timeMemory
422881pliamParrots (IOI11_parrots)C++14
98 / 100
11 ms1324 KiB
#include "encoder.h" #include "encoderlib.h" void sendcnt(int a,int x){ for(int i=0;i<x;i++){ send(a); } } void encode(int N, int M[]) { //4-ary system int cnt1=0,cnt2=0; for(int num=0;num<N;num++){ int tmp=M[num]; for(int pos=0;pos<4;pos++){ int cnt=tmp&3;//mod4=mod(2^2), we keep last 2 digits cnt1+=cnt; cnt2+=(3-cnt); tmp>>=2; } } bool change=(cnt2<cnt1); if(change) sendcnt(255,4); for(int num=0;num<N;num++){ for(int pos=0;pos<4;pos++){ int cnt=M[num]&3;//mod4=mod(2^2), we keep last 2 digits sendcnt((num<<2)|pos,change?(3-cnt):cnt); M[num]>>=2; } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; void decode(int N, int L, int X[]) { map<int,int> freq; for(int i=0;i<L;i++){ freq[X[i]]++; } //4-ary system bool change=false; if(freq.count(255)){ if(freq[255]>=4){ change=true; freq[255]-=4; } } for(int num=0;num<N;num++){ int val=0; for(int pos=0;pos<4;pos++){ int mask=(num<<2)|pos; if(freq.count(mask)){ val|=(1<<(2*pos))*(change?3-freq[mask]:freq[mask]); }else{ val|=(1<<(2*pos))*(change?3:0); } } output(val); } }
#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...