이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <map>
const int MAXN = 64 + 6;
const int MAXNUM = 256 + 6;
struct State2
{
int state[5];
State2()
{
std::fill(state, state + 5, 0);
}
};
int cnt2 = 0;
State2 convert[MAXNUM];
void brute(int left, int pos, State2 state)
{
if (pos == 4)
{
if (cnt2 >= 256)
{
return;
}
state.state[pos] = left;
convert[cnt2++] = state;
return;
}
brute(left, pos + 1, state);
if (left >= 1)
{
state.state[pos]++;
brute(left - 1, pos, state);
}
}
bool was2 = false;
void encode(int N, int M[])
{
if (!was2)
{
State2 state;
brute(7, 0, state);
}
for (int i = 0 ; i < N ; ++i)
{
for (int j = 0 ; j < 4 ; ++j)
{
for (int k = 0 ; k < convert[M[i]].state[j] ; ++k)
{
send(N * j + i);
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <map>
const int MAXN = 64 + 6;
struct State
{
int state[5];
State()
{
std::fill(state, state + 5, 0);
}
friend bool operator < (const State &a, const State &b)
{
for (int i = 0 ; i < 5 ; ++i)
{
if (a.state[i] < b.state[i]) return true;
if (a.state[i] > b.state[i]) return false;
}
return false;
}
};
int cnt;
bool was = false;
std::map <State,int> mp;
void brute(int left, int pos, State state)
{
if (pos == 4)
{
if (cnt >= 256)
{
return;
}
state.state[pos] = left;
mp[state] = cnt++;
return;
}
brute(left, pos + 1, state);
if (left >= 1)
{
state.state[pos]++;
brute(left - 1, pos, state);
}
}
int ans[MAXN];
int lastBit[MAXN];
State a[MAXN];
void decode(int N, int L, int X[])
{
if (!was)
{
cnt = 0;
mp.clear();
State state;
brute(7, 0, state);
was = true;
}
for (int i = 0 ; i < N ; ++i)
{
ans[i] = 0;
for (int j = 0 ; j < 4 ; ++j)
{
a[i].state[j] = 0;
}
a[i].state[4] = 7;
}
for (int i = 0 ; i < L ; ++i)
{
a[X[i] % N].state[4]--;
a[X[i] % N].state[X[i] / N]++;
}
for (int i = 0 ; i < N ; ++i)
{
output(mp[a[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... |