#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int n, int m[]){
for(int i=0; i<n; i++){
vector<int> stuff;
for(int j=6; j>=0; j-=2){
stuff.push_back(((m[i]>>j)&0b11));
send((i*2+(j<4?1:0))*4+((m[i]>>j)&0b11));
}
if(stuff[0]<stuff[1]){
send(i*2*4);
send(i*2*4);
send(i*2*4);
}
else{
send(i*2*4+1);
send(i*2*4+1);
send(i*2*4+1);
}
if(stuff[2]<stuff[3]){
send((i*2+1)*4);
send((i*2+1)*4);
send((i*2+1)*4);
}
else{
send((i*2+1)*4+1);
send((i*2+1)*4+1);
send((i*2+1)*4+1);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int n, int l, int x[]){
map<int,int> got,done;
vector<int> ord;
for(int i=0; i<l; i++){
got[x[i]]++;
if(done[x[i]]==0&&got[x[i]]==3){
ord.push_back(x[i]);
got[x[i]]-=3;
done[x[i]]=1;
}
}
vector<int> ok;
for(auto i:got) if(i.second!=3) for(int j=0; j<i.second; j++) ok.push_back(i.first);
int p=ok.size();
//cout << p << ' ';
assert(p%2==0);
vector<int> yes[100];
for(auto i:ok){
yes[i>>2].push_back(i&0b11);
}
for(int i:ord){
int y=i>>2;
if(i&1) sort(yes[y].begin(),yes[y].end(),greater<int>());
else sort(yes[y].begin(),yes[y].end());
}
vector<int> ans;
for(int i=0; i<100; i++) for(int j:yes[i]) ans.push_back(j);
for(int i=0; i<(int)ans.size(); i+=4){
output(ans[i]<<6|ans[i+1]<<4|ans[i+2]<<2|ans[i+3]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1308 KB |
Output is correct |
2 |
Correct |
3 ms |
1316 KB |
Output is correct |
3 |
Correct |
4 ms |
1316 KB |
Output is correct |
4 |
Correct |
4 ms |
1428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1316 KB |
Output is correct |
2 |
Correct |
3 ms |
1324 KB |
Output is correct |
3 |
Correct |
4 ms |
1420 KB |
Output is correct |
4 |
Correct |
4 ms |
1332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1320 KB |
Output is correct |
2 |
Correct |
4 ms |
1332 KB |
Output is correct |
3 |
Correct |
4 ms |
1336 KB |
Output is correct |
4 |
Correct |
8 ms |
1352 KB |
Output is correct |
5 |
Correct |
8 ms |
1352 KB |
Output is correct |
6 |
Correct |
8 ms |
1528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
4 ms |
1328 KB |
Output is partially correct - P = 10.000000 |
2 |
Partially correct |
9 ms |
1544 KB |
Output is partially correct - P = 10.000000 |
3 |
Incorrect |
0 ms |
792 KB |
Error : Bad encoded integer |
4 |
Halted |
0 ms |
0 KB |
- |