이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i <= b; i++)
void encode(int n, int M[])
{
vector<int> m;
rep(i,0,n-1) m.push_back(M[i]);
if(n > 32)
{
rep(j,0,(n%4)-1) m.push_back(255);
for(int i = 0; i < (n+3)/4; i++) {
int w = 0;
int poz = i*4;
if(m[poz] == 255) w += 1;
if(m[poz+1] == 255) w += 2;
if(m[poz+2] == 255) w += 4;
if(m[poz+3] == 255) w += 8;
int ans = i + (w << 4);
send(ans);
send(ans);
send(ans);
send(ans);
}
rep(i,0,n/2-1)
{
if(m[i] == 255)
{
continue;
}
rep(bit,0,7)
{
if(m[i] & (1 << bit))
{
send(bit + (i << 3));
}
}
}
rep(i,n/2,n-1)
{
if(m[i] == 255)
{
continue;
}
rep(bit,0,7)
{
if(m[i] & (1 << bit))
{
send(bit + ((i%(n/2-1)) << 3));
send(bit + ((i%(n/2-1)) << 3));
}
}
}
return;
}
rep(i,0,n-1)
{
rep(bit,0,7)
{
if(m[i] & (1 << bit))
{
send(bit + (i << 3));
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i <= b; i++)
void decode(int n, int l, int x[])
{
vector<int> ans(n+4,0);
if(n <= 32)
{
rep(i,0,l-1)
{
int bit = 0;
if(x[i] & 1) bit += 1;
if(x[i] & 2) bit += 2;
if(x[i] & 4) bit += 4;
int poz = x[i] >> 3;
ans[poz] |= (1 << bit);
}
}
else
{
map<int,int> zlicz;
rep(i,0,l-1) zlicz[x[i]]++;
rep(i,0,l-1)
{
if(zlicz[x[i]] == 1 || zlicz[x[i]] == 3)
{
int bit = 0;
if(x[i] & 1) bit += 1;
if(x[i] & 2) bit += 2;
if(x[i] & 4) bit += 4;
int poz = x[i] >> 3;
ans[poz] |= (1 << bit);
}
if(zlicz[x[i]] == 3)
{
int bit = 0;
if(x[i] & 1) bit += 1;
if(x[i] & 2) bit += 2;
if(x[i] & 4) bit += 4;
int poz = x[i] >> 3;
ans[poz + n/2-1] |= (1 << bit);
}
if(zlicz[x[i]] == 4)
{
int blok = x[i] & (1+2+4+8);
int is = x[i] & (16+32+64+128);
int p = 0;
rep(j,blok*4,blok*4+3)
{
if(is & (1 << p)) ans[j] = 255;
p++;
}
}
}
}
rep(i,0,n-1) 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... |