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 "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define vt vector
#define pb push_back
#define X first
#define Y second
using pii = pair<int,int>;
#define debug(x) do\
{auto _x=x; cerr<<#x<<" = "<<_x<<'\n';}while(0);
#define f0r(i,a,b) for(auto i=(a);i<(b);i++)
#define r0f(i,a,b) for(auto i=(a);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
// Bash out all the bits???
// Encode the first 2 position bits in the number of send times
// Encode the next 3 in the actual number [7,6,5]
// Encode the head/tail bit in actual number [4]
// use bit tricks to find head and tail
// Potential bug: zeroes in times
void mysend(int a, int times) {
f0r(i,0,times) send(a);
}
void encode(int N, int M[]) {
f0r(pos,0,N) {
int times = (pos >> 3) + 1;
int body = ((pos & ((1 << 3) - 1)) << 5);
int head = M[pos] >> 4;
int tail = M[pos] & ((1 << 4) - 1);
mysend(body | (1 << 4) | head, times);
mysend(body | tail, times);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define vt vector
#define pb push_back
#define X first
#define Y second
using pii = pair<int,int>;
#define debug(x) do\
{auto _x=x; cerr<<#x<<" = "<<_x<<'\n';}while(0);
#define f0r(i,a,b) for(auto i=(a);i<(b);i++)
#define r0f(i,a,b) for(auto i=(a);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
//potential bug: confusion between N and L
void decode(int d_sz, int N, int xs[]) {
vt<int> freq (255);
vt<int> ans (d_sz);
f0r(i,0,N) {
freq[xs[i]]++;
}
f0r(a,0,255) if(freq[a]) { //BUG : need to check if 0 times
int times = freq[a] - 1; //First 2 position bits
int nt = a >> 5; //Next 3 position bits
bool is_heads = !!(a & (1 << 4));
int block = a & ((1 << 4) - 1);
int where = (times << 3) + nt;
if(is_heads) {
ans[where] += block << 4;
} else {
ans[where] += block;
}
}
f0r(i,0,d_sz) {
output(ans[i]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |