#include"encoder.h"
#include"encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
void encode(int n,int a[]){
vector<int>best(n*15,0);
int sig;
for(int xr=0;xr<256;xr++){
vector<int>vec;
for(int i=0;i<n;i++){
int x=a[i]^xr;
while(x>63)vec.push_back((i<<2)|3),x-=64;
while(x>15)vec.push_back((i<<2)|2),x-=16;
while(x>3)vec.push_back((i<<2)|1),x-=4;
while(x>0)vec.push_back((i<<2)|0),x-=1;
}
if(vec.size()<best.size())best=vec,sig=xr;
}
for(auto to:best)send(to);
for(int i=0;i<5;i++)send(sig);
}
#include"decoder.h"
#include"decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
int res[64],counter[256];
void decode(int n,int m,int a[]){
for(int i=0;i<n;i++)res[i]=0;
for(int i=0;i<256;i++)counter[i]=0;
int mx=0,val;
for(int i=0;i<m;i++)
counter[a[i]]++;
for(int i=0;i<256;i++)if(counter[i]>mx)mx=counter[i],val=i;
mx=0;
for(int i=0;i<m;i++){
if(a[i]==val&&mx!=5){
mx++;
continue;
}
int data=a[i]&3;
if(data==0)res[a[i]>>2]+=1;
if(data==1)res[a[i]>>2]+=4;
if(data==2)res[a[i]>>2]+=16;
if(data==3)res[a[i]>>2]+=64;
}
for(int i=0;i<n;i++)output(res[i]^val);
}
Compilation message
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:20:29: warning: 'sig' may be used uninitialized in this function [-Wmaybe-uninitialized]
20 | for(int i=0;i<5;i++)send(sig);
| ~~~~^~~~~
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:25:31: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
25 | for(int i=0;i<n;i++)output(res[i]^val);
| ~~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1260 KB |
Output is correct |
2 |
Correct |
12 ms |
1136 KB |
Output is correct |
3 |
Correct |
15 ms |
1340 KB |
Output is correct |
4 |
Correct |
15 ms |
1316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1132 KB |
Output is correct |
2 |
Correct |
16 ms |
1136 KB |
Output is correct |
3 |
Correct |
15 ms |
1268 KB |
Output is correct |
4 |
Correct |
15 ms |
1140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1132 KB |
Output is correct |
2 |
Correct |
15 ms |
1140 KB |
Output is correct |
3 |
Correct |
21 ms |
1144 KB |
Output is correct |
4 |
Correct |
24 ms |
1312 KB |
Output is correct |
5 |
Correct |
25 ms |
1408 KB |
Output is correct |
6 |
Correct |
26 ms |
1284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
15 ms |
1316 KB |
Output is partially correct - P = 5.812500 |
2 |
Partially correct |
27 ms |
1328 KB |
Output is partially correct - P = 5.750000 |
3 |
Partially correct |
27 ms |
1284 KB |
Output is partially correct - P = 5.727273 |
4 |
Partially correct |
38 ms |
1304 KB |
Output is partially correct - P = 5.940000 |
5 |
Partially correct |
48 ms |
1464 KB |
Output is partially correct - P = 5.766667 |
6 |
Partially correct |
47 ms |
1696 KB |
Output is partially correct - P = 5.857143 |
7 |
Partially correct |
47 ms |
1448 KB |
Output is partially correct - P = 5.921875 |