# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125581 | thebes | 앵무새 (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 <bits/stdc++.h>
using namespace std;
map<vector<int>,int> mp;
map<int,vector<int>> rev;
vector<int> vec; int nxt;
void rec(int n){
if(n==3){
if(vec.size()!=5) return;
mp[vec]=nxt++;
rev[nxt-1]=vec;
}
else{
rec(n+1);
for(int i=1;i<=5;i++){
vec.push_back(n);
rec(n+1);
}
for(int i=0;i<5;i++)
vec.pop_back();
}
}
void encode(int N,int *M){
mp.clear(); rev.clear(); nxt = 0;
rec(0);
for(int i=0;i<N;i++){
int s = (M[i]&15);
int f = ((M[i]^s)>>4);
vector<int> w = rev[f];
for(auto v : w){
if(v==0) send(i*4);
else if(v==1) send(i*4+1);
}
w = rev[s];
for(auto v : w){
if(v==0) send(i*4+2);
else if(v==1) send(i*4+3);
}
}
}
#include <bits/stdc++.h>
using namespace std;
map<vector<int>,int> mp;
map<int,vector<int>> rev;
vector<int> vec; int nxt;
void rec(int n){
if(n==3){
if(vec.size()!=5) return;
mp[vec]=nxt++;
rev[nxt-1]=vec;
}
else{
rec(n+1);
for(int i=1;i<=5;i++){
vec.push_back(n);
rec(n+1);
}
for(int i=0;i<5;i++)
vec.pop_back();
}
}
vector<int> heh[200];
void decode(int N,int L,int *X){
mp.clear(); rev.clear(); nxt = 0;
rec(0);
for(int i=0;i<200;i++) heh[i].clear();
for(int i=0;i<L;i++){
int pog = (X[i]>>1);
heh[pog].push_back((X[i]&1));
}
for(int i=0;i<2*N;i++){
while(heh[i].size()<5)
heh[i].push_back(2);
sort(heh[i].begin(),heh[i].end());
}
for(int i=0;i<N;i++){
int f = mp[heh[2*i]];
int s = mp[heh[2*i+1]];
output((f<<4)+s);
}
}