#include<bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
//chia thanh 4 bit danh so vi tri 2 bit de danh so nhom 2 bit danh so value
int a[8];
int mul[4]={(1<<6),(1<<4),(1<<2),(1<<0)};
void encode(int n,int M[]){
for1(i,0,n-1){
int value=M[i];
int pos=(i)*(1<<4);
for1(j,0,7){
a[j]=(value>>j&1);
}
//0 1 to group 3, 2 3 to group 2, 4 5 to group 1, 6 7 to group 0
reverse(a,a+8);
int cnt=0;
for(int j=0;j<=7;j+=2){
int nval=a[j]*2+a[j+1];
int last4bit=(cnt*(1<<2)+nval);
send(pos+last4bit);
cnt++;
}
}
}
/*signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("temp.INP","r",stdin);
//freopen("temp.OUT","w",stdout);
encode(3,{10,30,20});
}*/
#include<bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
//chia thanh 4 bit danh so vi tri 2 bit de danh so nhom 2 bit danh so value
int mul[4]={(1<<6),(1<<4),(1<<2),(1<<0)};
int b[16];
void decode(int n,int l,int x[]){
for1(i,0,n-1)b[i]=0;
for1(i,0,l-1){
int vl=x[i];
int pos=(vl>>4);
int last4bit=vl%(1<<4);
int group=(last4bit>>2);
int valuegr=(last4bit%(1<<2));
b[pos]+=valuegr*mul[group];
}
for1(i,0,n-1)output(b[i]);
}
/*signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("temp.INP","r",stdin);
//freopen("temp.OUT","w",stdout);
encode(3,{10,30,20});
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1316 KB |
Output is correct |
2 |
Correct |
1 ms |
1320 KB |
Output is correct |
3 |
Correct |
1 ms |
1316 KB |
Output is correct |
4 |
Correct |
2 ms |
1316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1308 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
2 ms |
1320 KB |
Output is correct |
4 |
Correct |
1 ms |
1328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1308 KB |
Output is correct |
2 |
Correct |
1 ms |
1316 KB |
Output is correct |
3 |
Incorrect |
0 ms |
800 KB |
Error : Bad encoded integer |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1316 KB |
Output is correct - P = 4.000000 |
2 |
Incorrect |
1 ms |
804 KB |
Error : Bad encoded integer |
3 |
Incorrect |
0 ms |
884 KB |
Error : Bad encoded integer |
4 |
Incorrect |
0 ms |
912 KB |
Error : Bad encoded integer |
5 |
Incorrect |
0 ms |
796 KB |
Error : Bad encoded integer |
6 |
Incorrect |
0 ms |
1208 KB |
Error : Bad encoded integer |
7 |
Incorrect |
0 ms |
808 KB |
Error : Bad encoded integer |