# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347507 | daniel920712 | 앵무새 (IOI11_parrots) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "encoder.h"
#include "encoderlib.h"
#include <vector>
#include <algorithm>
using namespace std;
void encode(int N, int M[])
{
if(N<=32)
{
vector < pair < int , int > > all2;
int i,t=0;
for(i=0; i<N; i++)
{
send(M[i]);
send(M[i]);
send(M[i]);
send(M[i]);
all2.push_back(make_pair(M[i],i));
}
sort(all2.begin(),all2.end());
for(i=0;i<N;i++)
{
send(i/8*32+all2[i].second);
send(i/8*32+all2[i].second);
send(i%8*32+all2[i].second);
//printf("%d %d\n",i/8*32,i%8*32);
}
}
else
{
vector < int > a,b;
vector < int > all;
int i,j,now=0,x=0,y=0,K;
b.push_back(0);
b.push_back(0);
b.push_back(0);
b.push_back(0);
for(i=0;i<N;i++) for(j=7;j>=0;j--) all.push_back(M[i]&(1<<j));
K=all.size();
for(i=0;i<K;i++)
{
if(all[i]) for(j=0;j<1<<(i/256);j++) a.push_back(j%256);
else for(j=0;j<1<<(i/256);j++) b.push_back(j%256);
}
if(a.size()<b.size()) for(auto i:a) send(i);
else for(auto i:b) send(i);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
void decode(int N, int L, int X[])
{
if(N<=32)
{
vector < int > all;
map < int , int > con;
int ans[305];
int where[305];
int i,j, b;
for(i=0; i<L; i++)
{
con[X[i]]++;
}
for(auto i:con)
{
for(j=0;j<i.second/4;j++) all.push_back(i.first);
}
sort(all.begin(),all.end());
for(i=0;i<N;i++)
{
where[i]=0;
}
for(auto i:con)
{
if(i.second%4==2) where[i.first%32]+=i.first/32*8;
else if(i.second%4==1) where[i.first%32]+=i.first/32;
else if(i.second%4==3)
{
where[i.first%32]+=i.first/32;
where[i.first%32]+=i.first/32*8;
}
}
for(i=0; i<N; i++) output(all[where[i]]);
}
else
{
vector < int > all;
map < int , int > con;
int ans[605];
int i,j,ok=0,tt;
for(i=0; i<L; i++) con[X[i]]++;
for(auto i:con) if(i.second&4) ok=1;
for(i=0;i<8*N;i++) ans[i]=ok;
for(auto i:con)
{
if(i.second&2) ans[i.first+256]=1-ok;
if(i.second&1) ans[i.first]=1-ok;
}
for(i=0;i<N;i++)
{
tt=0;
for(j=0;j<8;j++) tt+=(1<<(7-j))*ans[8*i+j];
}
send(tt);
}
}