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;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int dp[11][5];
void preprocess() {
rep(j, 4) {
dp[10][j] = 4 - j;
}
for (int i = 9; i >= 1; i--) {
rep(j, 4){
dp[i][j] = 0;
for (int c = j; c < 4; c++) {
dp[i][j] += dp[i + 1][c];
}
// cout << "i = " << i << " j = " << j << " dp = " << dp[i][j] << '\n';
}
}
rep(i, 11) {
dp[i][4] = 0;
}
// cout << "KON" << endl;
}
void encode(int n, int T[])
{
preprocess();
rep(i, n) {
int pot = 1 << 6;
int it = 1;
while (it <= 10) {
int c = 3;
while (dp[it][c] <= T[i]) {
c--;
}
// cout << "c = " << c << " x = " << i + pot * c << endl;
T[i] -= dp[it][c + 1];
send(i + pot * c);
it++;
}
// cout << "WTH" << endl;
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int dp2[11][5];
void preprocess2() {
rep(j, 4) {
dp2[10][j] = 4 - j;
}
for (int i = 9; i >= 1; i--) {
rep(j, 4){
dp2[i][j] = 0;
for (int c = j; c < 4; c++) {
dp2[i][j] += dp2[i + 1][c];
}
// cout << "i = " << i << " j = " << j << " dp = " << dp[i][j] << '\n';
}
}
rep(i, 11) {
dp2[i][4] = 0;
}
// cout << "KON" << endl;
}
void decode(int n, int sz, int X[])
{
preprocess2();
vector<int> T[n];
rep(i, sz) {
int liczba = 0;
int pot = 1;
while (pot < 64) {
if (X[i] % 2 == 1) {
liczba += pot;
}
X[i] /= 2;
pot *= 2;
}
T[liczba].push_back(X[i]);
}
rep(i, n) {
sort(T[i].begin(), T[i].end());
// rep(j, T[i].size()) {
// cout << "i = " << i << " j = " << j << " T = " << T[i][j] << endl;
// }
int liczba = 0;
for (int it = 1; it <= 10; it++) {
liczba += dp2[it][T[i][it - 1] + 1];
}
cout << liczba << '\n';
output(liczba);
}
}
# | 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... |