# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52131 |
2018-06-24T06:09:04 Z |
노영훈(#1330, Diuven) |
Parrots (IOI11_parrots) |
C++11 |
|
0 ms |
0 KB |
#include "encoder.h"
#include "encoderlib.h"
#include <iostream>
using namespace std;
void encode(int N, int M[]){
int n=N;
if(n<=32){
for(int i=0; i<n; i++){
int base=i<<3, x=M[i];
for(int j=0; j<4; j++){
int now=base+(j<<1)+x%2;
send(now);
if(x&(1<<1)) send(now);
x>>=2;
}
}
}
else{
for(int i=0; i<n; i++){
int base=i<<2, x=M[i];
for(int j=0; j<4; j++){
int now=base+j;
for(int k=0; k<x%4; k++)
send(now);
x>>=2;
}
}
}
// cout<<"ENCODE!!\n";
// for(int i=0; i<n; i++)
// cout<<M[i]<<' ';
// cout<<'\n';
}
#include "decoder.h"
#include "decoderlib.h"
#include <iostream>
using namespace std;
void decode(int N, int L, int X[]){
int ans[64]={}, n=N, l=L;
if(n<=32){
bool dup[255]={};
for(int i=0; i<l; i++){
int x=X[i];
int idx=x>>3; x%=8;
int pos=x>>1; x%=2;
int val=x;
if(dup[X[i]]) val=2;
ans[idx]+=val<<(pos*2);
dup[X[i]]=true;
}
for(int i=0; i<n; i++) output(ans[i]);
}
else{
int cnt[255]={};
for(int i=0; i<l; i++){
cnt[x]++;
}
for(int i=0; i<256; i++){
int idx=x>>2; pos=x%4;
ans[idx]+=cnt[i]<<(pos*2);
}
for(int i=0; i<n; i++) output(ans[i]);
}
// cout<<"DECODE!!\n";
// for(int i=0; i<n; i++){
// cout<<ans[i]<<' ';
// }
// cout<<'\n';
}
Compilation message
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:24:17: error: 'x' was not declared in this scope
cnt[x]++;
^
decoder.cpp:27:21: error: 'x' was not declared in this scope
int idx=x>>2; pos=x%4;
^
decoder.cpp:27:27: error: 'pos' was not declared in this scope
int idx=x>>2; pos=x%4;
^~~